Commit e4c48a34 authored by Corey Frang's avatar Corey Frang Committed by timmywil

Landing pull request 496. 1.7 animate: allow named queues to be used by animate. Fixes #9280.

More Details:
 - https://github.com/jquery/jquery/pull/496
 - http://bugs.jquery.com/ticket/9280
parent af1dc64b
...@@ -126,7 +126,7 @@ jQuery.fn.extend({ ...@@ -126,7 +126,7 @@ jQuery.fn.extend({
// Do not change referenced properties as per-property easing will be lost // Do not change referenced properties as per-property easing will be lost
prop = jQuery.extend( {}, prop ); prop = jQuery.extend( {}, prop );
return this[ optall.queue === false ? "each" : "queue" ](function() { function doAnimation() {
// XXX 'this' does not always have a nodeName when running the // XXX 'this' does not always have a nodeName when running the
// test suite // test suite
...@@ -240,7 +240,11 @@ jQuery.fn.extend({ ...@@ -240,7 +240,11 @@ jQuery.fn.extend({
// For JS strict compliance // For JS strict compliance
return true; return true;
}); }
return optall.queue === false ?
this.each( doAnimation ) :
this.queue( optall.queue || "fx", doAnimation );
}, },
stop: function( clearQueue, gotoEnd ) { stop: function( clearQueue, gotoEnd ) {
...@@ -335,7 +339,7 @@ jQuery.extend({ ...@@ -335,7 +339,7 @@ jQuery.extend({
} }
if ( opt.queue !== false ) { if ( opt.queue !== false ) {
jQuery.dequeue( this ); jQuery.dequeue( this, opt.queue || "fx" );
} else if ( noUnmark !== false ) { } else if ( noUnmark !== false ) {
jQuery._unmark( this ); jQuery._unmark( this );
} }
......
...@@ -357,6 +357,41 @@ test("animate option (queue === false)", function () { ...@@ -357,6 +357,41 @@ test("animate option (queue === false)", function () {
}); });
*/ */
asyncTest( "animate option { queue: 'name' }", function() {
expect( 5 );
var foo = jQuery( "#foo" ),
origWidth = foo.width(),
order = [];
foo.animate( { width: origWidth + 100 }, {
queue: 'name',
duration: 1,
complete: function() {
// second callback function
order.push( 2 );
equals( foo.width(), origWidth + 100, "Animation ended" );
equals( foo.queue("name").length, 1, "Queue length of 'name' queue" );
}
}).queue( "name", function( next ) {
// last callback function
deepEqual( order, [ 1, 2 ], "Callbacks in expected order" );
start();
});
setTimeout( function() {
// this is the first callback function that should be called
order.push( 1 );
equals( foo.width(), origWidth, "Animation does not start on its own." );
equals( foo.queue("name").length, 2, "Queue length of 'name' queue" );
foo.dequeue( "name" );
}, 100 );
});
test("animate with no properties", function() { test("animate with no properties", function() {
expect(2); expect(2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment