I have been using jQuery's stop(true, true)
method to clear running animations so the next one starts immediately. I noticed that the first parameter, clearQueue
, clears the entire animation queue but the second parameter, jumpToEnd
, only jumps to the end of the currently running animation and not the ones that were removed from the queue. Is there a way to have it clear and jump to the end of all queued animations?
I've ended up chaining a few stop(false, true)
calls instead, but this will only handle 3 queued animations, for example.
$(this)
.stop(false, true)
.stop(false, true)
.stop(false, true)
.addClass('hover', 200);
Edit:
I ended up adding my own method, stopAll
, as per Ates Goral's answer:
$.fn.extend({ stopAll: function () {
while (this.queue().length > 0)
this.stop(false, true);
return this;
} });
$(this).stopAll().addClass('hover', 200);
I hope someone else finds this useful.