]> source.dussan.org Git - jquery.git/commitdiff
Fix #13483. Let slideDown() work after stop(). Close gh-1205.
authorRenato Oliveira dos Santos <ros3@cin.ufpe.br>
Sun, 17 Mar 2013 06:40:18 +0000 (03:40 -0300)
committerDave Methvin <dave.methvin@gmail.com>
Wed, 17 Apr 2013 03:07:39 +0000 (23:07 -0400)
AUTHORS.txt
src/effects.js
test/unit/effects.js

index fea67a6c36e96115a6e44acb18c43491f85dff9b..9ce13edf2978aaf3d5cab4d08a4440b0ff2119b7 100644 (file)
@@ -166,3 +166,4 @@ Dmitry Gusev <dmitry.gusev@gmail.com>
 Michał Gołębiowski <m.goleb@gmail.com>
 Steven Benner <admin@stevenbenner.com>
 Li Xudong <istonelee@gmail.com>
+Renato Oliveira dos Santos <ros3@cin.ufpe.br>
index 7f54dd56ea442b28d138396a903c9ea9e0298dc3..a1ba377074d31548d30ea0cab3abe111fc7bfc00 100644 (file)
@@ -304,21 +304,29 @@ function defaultPrefilter( elem, props, opts ) {
 
 
        // show/hide pass
+       dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} );
        for ( index in props ) {
                value = props[ index ];
                if ( rfxtypes.exec( value ) ) {
                        delete props[ index ];
                        toggle = toggle || value === "toggle";
                        if ( value === ( hidden ? "hide" : "show" ) ) {
+
+                               // 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[ index ] !== undefined ) {
+                                       hidden = true;
+                               } else {
                                continue;
                        }
+                       }
                        handled.push( index );
                }
        }
 
        length = handled.length;
-       if ( length ) {
+       if ( !length ) {
                dataShow = data_priv.get( elem, "fxshow" ) || data_priv.access( elem, "fxshow", {} );
+       } else {
                if ( "hidden" in dataShow ) {
                        hidden = dataShow.hidden;
                }
index b8e49ba45a7e5e4339d1c24a08ee6337e683145a..1b2bee85aeb25199f0780a59a39337a20b0112f7 100644 (file)
@@ -2033,4 +2033,64 @@ test( ".finish() calls finish of custom queue functions", function() {
        div.remove();
 });
 
+asyncTest( "slideDown() after stop() (#13483)", 2, function() {
+       var ul = jQuery( "<ul style='height: 100px;display: block'></ul>" ),
+               origHeight = ul.height();
+
+       // First test. slideUp() -> stop() in the middle -> slideDown() until the end
+       ul.slideUp( 1000 );
+       setTimeout( function() {
+               ul.stop( true );
+               ul.slideDown( 1, function() {
+                       equal( ul.height(), origHeight, "slideDown() after interrupting slideUp() with stop(). Height must be in original value" );
+
+                       // Second test. slideDown() -> stop() in the middle -> slideDown() until the end
+                       ul.slideUp( 1, function() {
+                               ul.slideDown( 1000 );
+                               setTimeout( function() {
+                                       ul.stop( true );
+                                       ul.slideDown( 1, function() {
+                                               equal( ul.height(), origHeight, "slideDown() after interrupting slideDown() with stop(). Height must be in original value" );
+
+                                               // Cleanup
+                                               ul.remove();
+                                               start();
+                                       });
+                               }, 500 );
+                       });
+
+               });
+       }, 500 );
+});
+
+asyncTest( "fadeIn() after stop() (related to #13483)", 2, function() {
+       var ul = jQuery( "<ul style='height: 100px;display: block; opacity: 1'></ul>" ),
+               origOpacity = ul.css( "opacity" );
+
+       // First test. fadeOut() -> stop() in the middle -> fadeIn() until the end
+       ul.fadeOut( 1000 );
+       setTimeout( function() {
+               ul.stop( true );
+               ul.fadeIn( 1, function() {
+                       equal( ul.css( "opacity" ), origOpacity, "fadeIn() after interrupting fadeOut() with stop(). Opacity must be in original value" );
+
+                       // Second test. fadeIn() -> stop() in the middle -> fadeIn() until the end
+                       ul.fadeOut( 1, function() {
+                               ul.fadeIn( 1000 );
+                               setTimeout( function() {
+                                       ul.stop( true );
+                                       ul.fadeIn( 1, function() {
+                                               equal( ul.css("opacity"), origOpacity, "fadeIn() after interrupting fadeIn() with stop(). Opacity must be in original value" );
+
+                                               // Cleanup
+                                               ul.remove();
+                                               start();
+                                       });
+                               }, 500 );
+                       });
+
+               });
+       }, 500 );
+});
+
 })();