#13937 closed bug (fixed)
finish() only finishes last item of a set being .animate()d.
Reported by: | Owned by: | gibson042 | |
---|---|---|---|
Priority: | low | Milestone: | 1.10.1/2.0.2 |
Component: | effects | Version: | 1.9.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
When calling finish() after a set of items is animated, only the last item in the set is correctly finished; the rest are just frozen without finishing.
Another symptom of the same bug: if calling finish() to finish a single selected item of a set of items being animated, the selected item is frozen, and the last in the original animating set is finished instead.
Minimal repro: http://jsfiddle.net/dUGVJ/
Notice: although number 2 gets .finish() called, instead 3 actually finishes and 2 is frozen and unfinished.
The bug is on line 491 of effects.js:
doAnimation.finish = function() { anim.stop( true ); };
The instance of the doAnimation closure is shared across all items being animated, so modifying doAnimation.finish changes shared state, and the last one wins: calling finish() on an animation in progress ends up calling anim.stop for the last anim instance only.
Change History (6)
comment:1 Changed 10 years ago by
comment:2 follow-up: 3 Changed 10 years ago by
Owner: | set to david.bau@… |
---|---|
Status: | new → assigned |
Confirmed. Would you like to file a pull request at http://github.com/jquery/jquery and get the contributor credit?
comment:3 Changed 10 years ago by
Replying to gibson042:
Would you like to file a pull request at http://github.com/jquery/jquery and get the contributor credit?
I'd prefer that somebody on the jquery team make the fix. Thanks!!
comment:4 Changed 10 years ago by
Component: | unfiled → effects |
---|---|
Owner: | changed from david.bau@… to gibson042 |
Priority: | undecided → low |
comment:5 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fix #13937: Correctly scope .finish() following multi-element .animate(). Thanks @gnarf37. Close gh-1279. (cherry picked from commit ae9e05e9f3cb071232b056005755acb5926e403e)
Changeset: 6fd5e480c1cd3e481e7097763ee281b65bc74306
comment:6 Changed 10 years ago by
Milestone: | None → 1.10.1/2.0.2 |
---|
Here is a possible way to change of animate() to fix this issue. The idea is to track the anims in a doAnimation.active array, and make finish() find the right matching anim to stop.