@@ -16,15 +16,18 @@ $.effects.effect.fold = function( o, next ) {
1616
1717 // Create element
1818 var el = $ ( this ) ,
19- props = [ "position" , "top" , "bottom" , "left" , "right" , "height" , "width" ] ,
20- mode = $ . effects . setMode ( el , o . mode || "hide" ) ,
19+ props = [ "position" , "top" , "bottom" , "left" , "right" , "height" , "width" ] ,
20+ mode = $ . effects . setMode ( el , o . mode || "hide" ) ,
21+ show = mode === "show" ,
22+ hide = mode === "hide" ,
2123 size = o . size || 15 ,
22- percent = / ( [ 0 - 9 ] + ) % / . exec ( size ) ,
24+ percent = / ( [ 0 - 9 ] + ) % / . exec ( size ) ,
2325 horizFirst = ! ! o . horizFirst ,
24- widthFirst = ( ( mode == " show" ) != horizFirst ) ,
25- ref = widthFirst ? [ "width" , "height" ] : [ "height" , "width" ] ,
26+ widthFirst = show != horizFirst ,
27+ ref = widthFirst ? [ "width" , "height" ] : [ "height" , "width" ] ,
2628 duration = o . duration / 2 ,
27- wrapper , distance ;
29+ wrapper , distance ,
30+ animation1 = { } , animation2 = { } ;
2831
2932 $ . effects . save ( el , props ) ;
3033 el . show ( ) ;
@@ -38,29 +41,34 @@ $.effects.effect.fold = function( o, next ) {
3841 [ wrapper . height ( ) , wrapper . width ( ) ] ;
3942
4043 if ( percent ) {
41- size = parseInt ( percent [ 1 ] , 10 ) / 100 * distance [ ( mode == " hide" ) ? 0 : 1 ] ;
44+ size = parseInt ( percent [ 1 ] , 10 ) / 100 * distance [ hide ? 0 : 1 ] ;
4245 }
43- mode == "show" && wrapper . css ( horizFirst ? {
46+ if ( show ) {
47+ wrapper . css ( horizFirst ? {
4448 height : 0 ,
4549 width : size
4650 } : {
4751 height : size ,
4852 width : 0
4953 } ) ;
54+ }
5055
5156 // Animation
52- var animation1 = { } , animation2 = { } ;
53- animation1 [ ref [ 0 ] ] = mode == "show" ? distance [ 0 ] : size ;
54- animation2 [ ref [ 1 ] ] = mode == "show" ? distance [ 1 ] : 0 ;
57+ animation1 [ ref [ 0 ] ] = show ? distance [ 0 ] : size ;
58+ animation2 [ ref [ 1 ] ] = show ? distance [ 1 ] : 0 ;
5559
5660 // Animate
5761 wrapper
5862 . animate ( animation1 , duration , o . easing )
5963 . animate ( animation2 , duration , o . easing , function ( ) {
60- ( mode == "hide" ) && el . hide ( ) ;
64+ if ( hide ) {
65+ el . hide ( ) ;
66+ }
6167 $ . effects . restore ( el , props ) ;
6268 $ . effects . removeWrapper ( el ) ;
63- jQuery . isFunction ( o . complete ) && o . complete . apply ( el [ 0 ] , arguments ) ;
69+ if ( $ . isFunction ( o . complete ) ) {
70+ o . complete . apply ( el [ 0 ] , arguments ) ;
71+ }
6472 next ( ) ;
6573 } ) ;
6674
0 commit comments