Skip to content

Commit 0fea007

Browse files
gnarfdmethvin
authored andcommitted
Fix #12273. Don't call easing functions for duration 0 animations. Close jquerygh-895.
1 parent 3812f94 commit 0fea007

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/effects.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,13 @@ Tween.prototype = {
376376
var eased,
377377
hooks = Tween.propHooks[ this.prop ];
378378

379-
this.pos = eased = jQuery.easing[ this.easing ]( percent, this.options.duration * percent, 0, 1, this.options.duration );
379+
if ( this.options.duration ) {
380+
this.pos = eased = jQuery.easing[ this.easing ](
381+
percent, this.options.duration * percent, 0, 1, this.options.duration
382+
);
383+
} else {
384+
this.pos = eased = percent;
385+
}
380386
this.now = ( this.end - this.start ) * eased + this.start;
381387

382388
if ( this.options.step ) {

test/unit/effects.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,4 +1811,22 @@ test( "Animate properly sets overflow hidden when animating width/height (#12117
18111811
});
18121812
});
18131813

1814+
test( "Animations with 0 duration don't ease (#12273)", 1, function() {
1815+
jQuery.easing.test = function() {
1816+
ok( false, "Called easing" );
1817+
};
1818+
1819+
jQuery( "#foo" ).animate({
1820+
height: 100
1821+
}, {
1822+
duration: 0,
1823+
easing: "test",
1824+
complete: function() {
1825+
equal( jQuery( this ).height(), 100, "Height is 100" );
1826+
}
1827+
});
1828+
1829+
delete jQuery.easing.test;
1830+
});
1831+
18141832
} // if ( jQuery.fx )

0 commit comments

Comments
 (0)