]> source.dussan.org Git - jquery.git/commitdiff
Fix #12273. Don't call easing functions for duration 0 animations. Close gh-895.
authorCorey Frang <gnarf@gnarf.net>
Wed, 15 Aug 2012 19:31:37 +0000 (14:31 -0500)
committerDave Methvin <dave.methvin@gmail.com>
Mon, 20 Aug 2012 02:09:08 +0000 (22:09 -0400)
src/effects.js
test/unit/effects.js

index 3405cfdc2f78683c8232644bc900114af1003aa1..cc2a26a1e6aa1287dd55f0b6064dace782212817 100644 (file)
@@ -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 ) {
index 0eb2a315612b64d41c9c1cc49554ecd48b4cc1b2..70b18146146a27313ec71a498c60cc4175f6c0d8 100644 (file)
@@ -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 )