我使用animate循環改變element的top值,當mouseenter時,用stop暫停,mouseleave時,繼續執行該函數,可是當鼠標劃入劃出時,動畫速度明顯減緩,后來用setInterval解決了,可是不知道為什么會發生這中情況。function doanimate(){
div.animate({
top:'450px'
},1000,'linear',function(){
div.css('top','0px');
});
}
div.on('mouseenter mouseleaver',function(e){ if(e.type == 'mouseenter'){
div.stop(true);
} else if(e.type =='mouseleave'){
doanimate();
}
}
jquery的animate多次執行后動畫速度變慢
慕姐8265434
2018-08-10 09:10:09