我使用animate循环改变element的top值,当mouseenter时,用stop暂停,mouseleave时,继续执行该函数,可是当鼠标划入划出时,动画速度明显减缓,后来用setInterval解决了,可是不知道为什么会发生这中情况。
function doanimate(){
p.animate({
top:'450px'
},1000,'linear',function(){
p.css('top','0px');
});
}
p.on('mouseenter mouseleaver',function(e){
if(e.type == 'mouseenter'){
p.stop(true);
}
else if(e.type =='mouseleave'){
doanimate();
}
}
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...