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,
19
19
20
20
module ( "effects.core" ) ;
21
21
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
+
22
34
$ . each ( $ . effects . effect , function ( effect ) {
23
35
if ( effect === "transfer" ) {
24
36
return ;
Original file line number Diff line number Diff line change @@ -556,19 +556,26 @@ $.fn.extend({
556
556
}
557
557
558
558
function run ( next ) {
559
- var elem = this ,
560
- complete = args . complete ;
559
+ var elem = $ ( this ) ,
560
+ complete = args . complete ,
561
+ mode = args . mode ;
561
562
562
563
function done ( ) {
563
564
if ( $ . isFunction ( complete ) ) {
564
- complete . call ( elem ) ;
565
+ complete . call ( elem [ 0 ] ) ;
565
566
}
566
567
if ( $ . isFunction ( next ) ) {
567
568
next ( ) ;
568
569
}
569
570
}
570
571
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
+ }
572
579
}
573
580
574
581
// TODO: remove this check in 2.0, effectMethod will always be true
You can’t perform that action at this time.
0 commit comments