File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed
Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,18 @@ var minDuration = 15,
1919
2020module ( "effects.core" ) ;
2121
22+ test ( "Immediate Return Conditions" , function ( ) {
23+ var hidden = $ ( "div.hidden" ) ,
24+ count = 0 ;
25+ expect ( 6 ) ;
26+ hidden . hide ( "blind" , function ( ) {
27+ equal ( ++ count , 1 , "Hide on hidden returned immediately" ) ;
28+ } ) . show ( ) . show ( "blind" , function ( ) {
29+ equal ( ++ count , 2 , "Show on shown returned immediately" ) ;
30+ } ) ;
31+ equal ( ++ count , 3 , "Both Functions worked properly" ) ;
32+ } ) ;
33+
2234$ . each ( $ . effects . effect , function ( effect ) {
2335 if ( effect === "transfer" ) {
2436 return ;
Original file line number Diff line number Diff line change @@ -556,19 +556,26 @@ $.fn.extend({
556556 }
557557
558558 function run ( next ) {
559- var elem = this ,
560- complete = args . complete ;
559+ var elem = $ ( this ) ,
560+ complete = args . complete ,
561+ mode = args . mode ;
561562
562563 function done ( ) {
563564 if ( $ . isFunction ( complete ) ) {
564- complete . call ( elem ) ;
565+ complete . call ( elem [ 0 ] ) ;
565566 }
566567 if ( $ . isFunction ( next ) ) {
567568 next ( ) ;
568569 }
569570 }
570571
571- effectMethod . call ( elem , args , done ) ;
572+ // if the element is hiddden and mode is hide,
573+ // or element is visible and mode is show
574+ if ( elem . is ( ":hidden" ) ? mode === "hide" : mode === "show" ) {
575+ done ( ) ;
576+ } else {
577+ effectMethod . call ( elem [ 0 ] , args , done ) ;
578+ }
572579 }
573580
574581 // TODO: remove this check in 2.0, effectMethod will always be true
You can’t perform that action at this time.
0 commit comments