我使用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(); } }
相关分类