jQuery - How to Prevent Animation Queue Buildup with Double Animations?
Posted
by Jason
on Stack Overflow
See other posts from Stack Overflow
or by Jason
Published on 2009-12-23T01:54:59Z
Indexed on
2010/05/12
0:04 UTC
Read the original article
Hit count: 160
Hello,
I was taking a look at this tutorial here to prevent animation buildups:
http://www.learningjquery.com/2009/01/quick-tip-prevent-animation-queue-buildup
My situation: I am doing a double animation like this below, and would like the prevent the animation build up. Since I have 2 animations going, it seems it ignores the .stop(). What can be done to prevent this? I have tried .stop() on both .animate and if I do that it stops animating...
$(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',
});
});
});
Any help will be greatly aprecaited!!
© Stack Overflow or respective owner