From 0fea007a1a4d6456a8c7d246e4f7a4e14a1ba04a Mon Sep 17 00:00:00 2001 From: Corey Frang Date: Wed, 15 Aug 2012 14:31:37 -0500 Subject: [PATCH] Fix #12273. Don't call easing functions for duration 0 animations. Close gh-895. --- src/effects.js | 8 +++++++- test/unit/effects.js | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/effects.js b/src/effects.js index 3405cfdc2..cc2a26a1e 100644 --- a/src/effects.js +++ b/src/effects.js @@ -376,7 +376,13 @@ Tween.prototype = { var eased, hooks = Tween.propHooks[ this.prop ]; - this.pos = eased = jQuery.easing[ this.easing ]( percent, this.options.duration * percent, 0, 1, this.options.duration ); + if ( this.options.duration ) { + this.pos = eased = jQuery.easing[ this.easing ]( + percent, this.options.duration * percent, 0, 1, this.options.duration + ); + } else { + this.pos = eased = percent; + } this.now = ( this.end - this.start ) * eased + this.start; if ( this.options.step ) { diff --git a/test/unit/effects.js b/test/unit/effects.js index 0eb2a3156..70b181461 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -1811,4 +1811,22 @@ test( "Animate properly sets overflow hidden when animating width/height (#12117 }); }); +test( "Animations with 0 duration don't ease (#12273)", 1, function() { + jQuery.easing.test = function() { + ok( false, "Called easing" ); + }; + + jQuery( "#foo" ).animate({ + height: 100 + }, { + duration: 0, + easing: "test", + complete: function() { + equal( jQuery( this ).height(), 100, "Height is 100" ); + } + }); + + delete jQuery.easing.test; +}); + } // if ( jQuery.fx ) -- 2.39.5