【发布时间】:2009-12-23 01:54:59
【问题描述】:
我在这里查看本教程以防止动画堆积:
http://www.learningjquery.com/2009/01/quick-tip-prevent-animation-queue-buildup
我的情况: 我正在做一个像下面这样的双重动画,并希望防止动画建立。由于我有 2 个动画,它似乎忽略了 .stop()。可以做些什么来防止这种情况发生?我在 .animate 上都尝试过 .stop() ,如果我这样做了,它会停止动画......
$(document).ready(function() {
$('#element').hover(function() {
$(this).stop()
.animate(
{ left: 200 }, {
duration: 'slow',
})
.animate(
{ top: 200 }, {
duration: 'slow',
});
} , function() {
$(this).stop()
.animate(
{ left: 0 }, {
duration: 'slow',
})
.animate(
{ top: 0 }, {
duration: 'slow',
});
});
});
任何帮助将不胜感激!
【问题讨论】: