type = type || "fx";
var queue = jQuery.queue( elem, type ),
+ startLength = queue.length,
fn = queue.shift(),
hooks = jQuery._queueHooks( elem, type ),
next = function() {
// If the fx queue is dequeued, always remove the progress sentinel
if ( fn === "inprogress" ) {
fn = queue.shift();
+ startLength--;
}
if ( fn ) {
delete hooks.stop;
fn.call( elem, next, hooks );
}
- if ( !queue.length && hooks ) {
+
+ if ( !startLength && hooks ) {
hooks.empty.fire();
}
},
type = type || "fx";
while( i-- ) {
- if ( (tmp = jQuery._data( elements[ i ], type + "queueHooks" )) && tmp.empty ) {
+ tmp = jQuery._data( elements[ i ], type + "queueHooks" );
+ if ( tmp && tmp.empty ) {
count++;
tmp.empty.add( resolve );
}
module( "queue", { teardown: moduleTeardown });
-test( "queue() with other types", 12, function() {
+test( "queue() with other types", 14, function() {
var counter = 0;
stop();
equal( counter, 4, "Testing previous call to dequeue" );
equal( $div.queue("foo").length, 0, "Testing queue length" );
+
+ $div.dequeue("foo");
+
+ equal( counter, 4, "Testing previous call to dequeue" );
+ equal( $div.queue("foo").length, 0, "Testing queue length" );
+
});
test("queue(name) passes in the next item in the queue as a parameter", function() {
}).queue( "queue", function( next ) {
strictEqual( test++, 2, "step two" );
setTimeout( function() {
- strictEqual( test++, 4, "step four" );
next();
+ strictEqual( test++, 4, "step four" );
start();
}, 10 );
}).promise( "queue" ).done( function() {
foo.dequeue( "queue" );
});
+asyncTest( "fn.promise( \"queue\" ) - waits for animation to complete before resolving", 2, function() {
+ var foo = jQuery( "#foo" ),
+ test = 1;
+
+ foo.animate({
+ top: 100
+ }, {
+ duration: 1,
+ queue: "queue",
+ complete: function() {
+ strictEqual( test++, 1, "step one" );
+ }
+ }).dequeue( "queue" );
+
+ foo.promise( "queue" ).done( function() {
+ strictEqual( test++, 2, "step two" );
+ start();
+ });
+
+});
+
test( ".promise(obj)", function() {
expect(2);