Call extend on prop to avoid changing original properties so that per-property easing is not lost in multiple animations with the same props
This commit is contained in:
parent
8bb6e95b66
commit
90f37aaf7a
5
src/effects.js
vendored
5
src/effects.js
vendored
|
@ -126,6 +126,9 @@ jQuery.fn.extend({
|
||||||
return this.each( optall.complete, [ false ] );
|
return this.each( optall.complete, [ false ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do not change referenced properties as per-property easing will be lost
|
||||||
|
prop = jQuery.extend( {}, prop );
|
||||||
|
|
||||||
return this[ optall.queue === false ? "each" : "queue" ](function() {
|
return this[ optall.queue === false ? "each" : "queue" ](function() {
|
||||||
// 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
|
||||||
|
@ -158,7 +161,7 @@ jQuery.fn.extend({
|
||||||
// easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default)
|
// easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default)
|
||||||
if ( jQuery.isArray( val ) ) {
|
if ( jQuery.isArray( val ) ) {
|
||||||
opt.animatedProperties[ name ] = val[ 1 ];
|
opt.animatedProperties[ name ] = val[ 1 ];
|
||||||
val = val[ 0 ];
|
val = prop[ name ] = val[ 0 ];
|
||||||
} else {
|
} else {
|
||||||
opt.animatedProperties[ name ] = opt.specialEasing && opt.specialEasing[ name ] || opt.easing || 'swing';
|
opt.animatedProperties[ name ] = opt.specialEasing && opt.specialEasing[ name ] || opt.easing || 'swing';
|
||||||
}
|
}
|
||||||
|
|
17
test/unit/effects.js
vendored
17
test/unit/effects.js
vendored
|
@ -923,13 +923,18 @@ test("jQuery.show('fast') doesn't clear radio buttons (bug #1095)", function ()
|
||||||
|
|
||||||
test("animate with per-property easing", function(){
|
test("animate with per-property easing", function(){
|
||||||
|
|
||||||
expect(3);
|
expect(5);
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
var data = { a:0, b:0, c:0 },
|
var data = { a:0, b:0, c:0 },
|
||||||
_test1_called = false,
|
_test1_called = false,
|
||||||
_test2_called = false,
|
_test2_called = false,
|
||||||
_default_test_called = false;
|
_default_test_called = false,
|
||||||
|
props = {
|
||||||
|
a: [ 100, "_test1" ],
|
||||||
|
b: [ 100, "_test2" ],
|
||||||
|
c: 100
|
||||||
|
};
|
||||||
|
|
||||||
jQuery.easing["_test1"] = function(p) {
|
jQuery.easing["_test1"] = function(p) {
|
||||||
_test1_called = true;
|
_test1_called = true;
|
||||||
|
@ -946,16 +951,14 @@ test("animate with per-property easing", function(){
|
||||||
return p;
|
return p;
|
||||||
};
|
};
|
||||||
|
|
||||||
jQuery(data).animate({
|
jQuery(data).animate( props, 400, "_default_test", function(){
|
||||||
a: [100, "_test1"],
|
|
||||||
b: [100, "_test2"],
|
|
||||||
c: 100
|
|
||||||
}, 400, "_default_test", function(){
|
|
||||||
start();
|
start();
|
||||||
|
|
||||||
ok( _test1_called, "Easing function (_test1) called" );
|
ok( _test1_called, "Easing function (_test1) called" );
|
||||||
ok( _test2_called, "Easing function (_test2) called" );
|
ok( _test2_called, "Easing function (_test2) called" );
|
||||||
ok( _default_test_called, "Easing function (_default) called" );
|
ok( _default_test_called, "Easing function (_default) called" );
|
||||||
|
equal( props.a[ 1 ], "_test1", "animate does not change original props (per-property easing would be lost)");
|
||||||
|
equal( props.b[ 1 ], "_test2", "animate does not change original props (per-property easing would be lost)");
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue