Skip to main content

Bug Tracker

Side navigation

#14753 closed bug (notabug)

Opened February 04, 2014 07:29AM UTC

Closed March 16, 2014 04:51PM UTC

finish() and stop(true, true) are inconsistent in their behavior with queue = false.

Reported by: archagon@gmail.com Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.10.2
Keywords: Cc:
Blocked by: Blocking:
Description

The behavior of stop(true, true) and finish() is inconsistent when the animating item has queue set to false in the animation options. With stop(true, true), the type argument in the jQuery call is set to undefined at the start of the function and matches type == null in the for ( index = timers.length; index--; )... block. With finish(), the missing type argument is set to "fx" and consequently does not match the timer's queue in the for ( index = timers.length; index--; ) ... block. Is this intended behavior? Calling finish(false) skirts around this issue, but it only handles the false queue, not every existing queue as does stop(true, true).

You can see this in action if you click "Go (no queue)" and then "finish()" in this JSFiddle: http://jsfiddle.net/wjg4L/

The reason this confused me was the documentation for finish(): "If the first argument is provided, only the animations in the queue represented by that string will be stopped. The .finish() method is similar to .stop(true, true) in that it clears the queue and the current animation jumps to its end value." The first sentence implies that if an argument is not provided, all queues will be stopped. The second sentence implies that the behavior should be similar to stop(true, true). It seems that neither is the case. Perhaps if type in finish() is undefined, it could handle every queue?

Attachments (0)
Change History (2)

Changed February 04, 2014 07:50AM UTC by archagon@gmail.com comment:1

A revised example showing how stop(true, true) clears every existing animation queue, while finish() only clears the one that's passed in (or fx by default): http://jsfiddle.net/JfE9g/

Changed March 16, 2014 04:51PM UTC by gnarf comment:2

resolution: → notabug
status: newclosed

I believe this was our intention with this method. Stop "the whole queue" worth of animations, so if you have animations in the queue: false and queue:"fx", you need to

 .finish( false ).finish() 
. It would actually be pretty hart to make .finish() iterate every queue.

This is more of a problem with the docs not explicitly saying that the default queue is "fx" and also should probably mention .finish( false )

https://github.com/jquery/api.jquery.com/issues/464