diff options
author | gnarf <gnarf@gnarf.net> | 2011-06-21 01:15:42 -0500 |
---|---|---|
committer | gnarf <gnarf@gnarf.net> | 2011-06-21 01:18:11 -0500 |
commit | 65a6c46e5568c43a9df9505e23da6a766814557e (patch) | |
tree | 63087dadabc63382d06c369062644fc64d252f5f /ui/jquery.effects.fold.js | |
parent | 1c1a3b1a361d90a73755fbd038b3cdfb0960c29f (diff) | |
download | jquery-ui-65a6c46e5568c43a9df9505e23da6a766814557e.tar.gz jquery-ui-65a6c46e5568c43a9df9505e23da6a766814557e.zip |
Effects.*: Style Guidance
Diffstat (limited to 'ui/jquery.effects.fold.js')
-rw-r--r-- | ui/jquery.effects.fold.js | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/ui/jquery.effects.fold.js b/ui/jquery.effects.fold.js index de7530bf0..b2a02ba78 100644 --- a/ui/jquery.effects.fold.js +++ b/ui/jquery.effects.fold.js @@ -16,15 +16,18 @@ $.effects.effect.fold = function( o, next ) { // Create element var el = $( this ), - props = ["position","top","bottom","left","right","height","width"], - mode = $.effects.setMode(el, o.mode || "hide"), + props = [ "position", "top", "bottom", "left", "right", "height", "width" ], + mode = $.effects.setMode( el, o.mode || "hide" ), + show = mode === "show", + hide = mode === "hide", size = o.size || 15, - percent = /([0-9]+)%/.exec(size), + percent = /([0-9]+)%/.exec( size ), horizFirst = !!o.horizFirst, - widthFirst = ((mode == "show") != horizFirst), - ref = widthFirst ? ["width", "height"] : ["height", "width"], + widthFirst = show != horizFirst, + ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ], duration = o.duration / 2, - wrapper, distance; + wrapper, distance, + animation1 = {}, animation2 = {}; $.effects.save( el, props ); el.show(); @@ -38,29 +41,34 @@ $.effects.effect.fold = function( o, next ) { [ wrapper.height(), wrapper.width() ]; if ( percent ) { - size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ ( mode == "hide") ? 0 : 1 ]; + size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ]; } - mode == "show" && wrapper.css( horizFirst ? { + if ( show ) { + wrapper.css( horizFirst ? { height: 0, width: size } : { height: size, width: 0 }); + } // Animation - var animation1 = {}, animation2 = {}; - animation1[ ref[ 0 ] ] = mode == "show" ? distance[ 0 ] : size; - animation2[ ref[ 1 ] ] = mode == "show" ? distance[ 1 ] : 0; + animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size; + animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0; // Animate wrapper .animate( animation1, duration, o.easing ) .animate( animation2, duration, o.easing, function() { - (mode == "hide") && el.hide(); + if ( hide ) { + el.hide(); + } $.effects.restore( el, props ); $.effects.removeWrapper( el ); - jQuery.isFunction(o.complete) && o.complete.apply( el[ 0 ], arguments ); + if ( $.isFunction( o.complete ) ) { + o.complete.apply( el[ 0 ], arguments ); + } next(); }); |