jquery的animate多次执行后动画速度变慢

我使用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();
    }
}


慕姐8265434
浏览 994回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript