【发布时间】:2012-02-28 19:22:27
【问题描述】:
我有一个这样的计时器设置:
var timerID;
$this.hover(function(){
$this.find('.stage_obj').each(function(index){
var current_obj = $(this);
timerID = setTimeout(function(){
animate_on_top(current_obj, index);}, parseInt(OS.delay_y_on_set[index],10));
});
}, function(){
clearTimeout(timerID);
});
有一些功能可以控制悬停时的动画进/出。计时器充当延迟(.delay 在我的情况下不起作用)。一切正常,除了鼠标退出时定时器没有取消,并且仍然触发。下面是实际调用的 animation_on 函数:
function animate_on_top(current_obj, index){
current_obj.animate(
{'top':OS.ends_y_set[index]},
{duration:500, queue:false,
specialEasing:{'top':'linear'}
});
有人知道为什么 setTimeout 没有取消计时器吗?谢谢!
【问题讨论】:
标签: javascript jquery timer settimeout