Description

The jQuery.fx tick() function removes an animation's timer from the timer list when the animation stops. However, if there is a call to stop() on the animated element within the animation's callback function, the call to stop() will remove the timer from the list and the tick() function will cause the next timer in the list to be removed instead, causing another animation on the page to freeze.

This could be solved either by documenting that stop() should not be called on the animation that fired the callback (after all, the animation is already stopped so the stop() call should not do anything), or by having tick() check that the animation which stopped is still in the queue before removing it.

I've attached a minimal test case for the bug, and a patch for tick().

I can still produce chaos in the exmaple ( ​http://jsfiddle.net/timmywil/gqZL5/24/ ), by clicking randomly on the "New Slide with stop" button. Sometimes animation gets stuck in the middle, and can not be recoverd without the reset button (animation will then only happen between 0 and 20% for example).
Here is an example, where you can reproduce the problem in no time:
​http://jsfiddle.net/4WhBL/9/ (running on the current (2011/9/11) git version of jquery)

I don't know whether this is exactly the case that this ticket is about, but all other better matching tickets have been closed as dupplicates of this one.

I think in fact, one can reduce the problem to ​http://jsfiddle.net/4WhBL/10/ simply calling .stop().fadeIn() .stop().fadeOut() .stop().fadeIn in this order, which should lead to a fade in, but doesn't.

I've looked into this a bit and it does not seem related to toggling. I haven't been able to reproduce this with random clicks (meaning it has not gotten stuck in the middle for me), only when the calls are in direct succession. That leads me to believe it has something to do with the timer on the animation itself, or perhaps the asynchronous call in the mark deferred. Reopening so we can dig in further.