我有一个计时器设置像这样:clearTimeout在鼠标离开
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不取消定时器?谢谢!
太神奇了!感谢Jared的快速,简洁和真棒的回应。使完美感:) – Aaron 2012-02-28 19:43:11