我有一個計時器設置像這樣: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