From: Richard Gibson Date: Fri, 30 Aug 2013 16:38:43 +0000 (-0400) Subject: Fix #14318: Cherry-pick interrupted animation fix from master ea5c22ec12e6a548b1ec2d7... X-Git-Tag: 1.11.0-beta1~58 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5cd6868365d74093883290337fa97b95c327d254;p=jquery.git Fix #14318: Cherry-pick interrupted animation fix from master ea5c22ec12e6a548b1ec2d7b0dcd9f71bea8d5dd --- diff --git a/src/effects.js b/src/effects.js index b936019fa..e708cb32b 100644 --- a/src/effects.js +++ b/src/effects.js @@ -337,7 +337,13 @@ function defaultPrefilter( elem, props, opts ) { delete props[ prop ]; toggle = toggle || value === "toggle"; if ( value === ( hidden ? "hide" : "show" ) ) { - continue; + + // If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden + if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { + hidden = true; + } else { + continue; + } } orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); } diff --git a/test/unit/effects.js b/test/unit/effects.js index ea8d93f5a..ac0e8a66d 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -2192,7 +2192,8 @@ asyncTest( ".finish() is applied correctly when multiple elements were animated }); asyncTest( "slideDown() after stop() (#13483)", 2, function() { - var ul = jQuery( "" ), + var ul = jQuery( "" ) + .appendTo("#qunit-fixture"), origHeight = ul.height(); // First test. slideUp() -> stop() in the middle -> slideDown() until the end @@ -2221,24 +2222,28 @@ asyncTest( "slideDown() after stop() (#13483)", 2, function() { }, 500 ); }); -asyncTest( "fadeIn() after stop() (related to #13483)", 2, function() { - var ul = jQuery( "" ), +asyncTest( "fadeIn() after stop() (related to #13483)", 5, function() { + var ul = jQuery( "" ) + .appendTo("#qunit-fixture").css( "opacity", 1 ), origOpacity = ul.css( "opacity" ); // First test. fadeOut() -> stop() in the middle -> fadeIn() until the end - ul.fadeOut( 1000 ); + ul.fadeOut( 2000 ); setTimeout( function() { ul.stop( true ); + ok( ul.css( "opacity" ) > 0, "fadeOut() interrupted" ); ul.fadeIn( 1, function() { - equal( ul.css( "opacity" ), origOpacity, "fadeIn() after interrupting fadeOut() with stop(). Opacity must be in original value" ); + equal( ul.css( "opacity" ), origOpacity, "fadeIn() restored original opacity after interrupted fadeOut()" ); // Second test. fadeIn() -> stop() in the middle -> fadeIn() until the end ul.fadeOut( 1, function() { - ul.fadeIn( 1000 ); + equal( ul.css( "opacity" ), origOpacity, "fadeOut() completed" ); + ul.fadeIn( 2000 ); setTimeout( function() { ul.stop( true ); + ok( ul.css( "opacity" ) < origOpacity, "fadeIn() interrupted" ); ul.fadeIn( 1, function() { - equal( ul.css("opacity"), origOpacity, "fadeIn() after interrupting fadeIn() with stop(). Opacity must be in original value" ); + equal( ul.css("opacity"), origOpacity, "fadeIn() restored original opacity after interrupted fadeIn()" ); // Cleanup ul.remove();