Fix for #1823 bug in animate {queue:false} plus a unit test.

This commit is contained in:
David Serduke 2007-11-16 17:49:12 +00:00
parent ab96367f12
commit 1d299d375b
2 changed files with 25 additions and 1 deletions

View file

@ -201,6 +201,7 @@ jQuery.extend({
// Queueing // Queueing
opt.old = opt.complete; opt.old = opt.complete;
opt.complete = function(){ opt.complete = function(){
if ( opt.queue !== false )
jQuery(this).dequeue(); jQuery(this).dequeue();
if ( jQuery.isFunction( opt.old ) ) if ( jQuery.isFunction( opt.old ) )
opt.old.apply( this ); opt.old.apply( this );

View file

@ -11,6 +11,29 @@ test("animate(Hash, Object, Function)", function() {
}); });
}); });
test("animate option (queue === false)", function () {
expect(1);
stop();
var order = [];
var $foo = $("#foo");
$foo.animate({width:'100px'}, 200, function () {
// should finish after unqueued animation so second
order.push(2);
});
$foo.animate({fontSize:'2em'}, {queue:false, duration:10, complete:function () {
// short duration and out of queue so should finish first
order.push(1);
}});
$foo.animate({height:'100px'}, 10, function() {
// queued behind the first animation so should finish third
order.push(3);
isSet( order, [ 1, 2, 3] );
start();
});
});
test("stop()", function() { test("stop()", function() {
expect(3); expect(3);
stop(); stop();