diff options
author | Kato Kazuyoshi <kato.kazuyoshi@gmail.com> | 2012-10-24 10:27:05 -0500 |
---|---|---|
committer | Corey Frang <gnarf@gnarf.net> | 2012-10-24 10:27:12 -0500 |
commit | 5f9d5c54c31546977792f4493b419f6c72fcc93e (patch) | |
tree | 616aab384ab96052795070ebea0c6a872192e6b2 /ui | |
parent | 721a4b4ae027b140ca280bbc8fb8ed334081b184 (diff) | |
download | jquery-ui-5f9d5c54c31546977792f4493b419f6c72fcc93e.tar.gz jquery-ui-5f9d5c54c31546977792f4493b419f6c72fcc93e.zip |
Effects (size): Adjusting behavior of toggled size effects - See gh-203 - Partial Fix for #7041
Diffstat (limited to 'ui')
-rw-r--r-- | ui/jquery.ui.effect-scale.js | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/ui/jquery.ui.effect-scale.js b/ui/jquery.ui.effect-scale.js index 933530a67..7fa04bed6 100644 --- a/ui/jquery.ui.effect-scale.js +++ b/ui/jquery.ui.effect-scale.js @@ -102,8 +102,9 @@ $.effects.effect.scale = function( o, done ) { $.effects.effect.size = function( o, done ) { // Create element - var el = $( this ), - props = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ], + var original, baseline, factor, + el = $( this ), + props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ], // Always restore props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ], @@ -119,8 +120,12 @@ $.effects.effect.size = function( o, done ) { restore = o.restore || mode !== "effect", scale = o.scale || "both", origin = o.origin || [ "middle", "center" ], - original, baseline, factor, - position = el.css( "position" ); + position = el.css( "position" ), + props = restore ? props0 : props1, + zero = { + height: 0, + width: 0 + }; if ( mode === "show" ) { el.show(); @@ -132,8 +137,13 @@ $.effects.effect.size = function( o, done ) { outerWidth: el.outerWidth() }; - el.from = o.from || original; - el.to = o.to || original; + if ( o.mode === "toggle" && mode === "show" ) { + el.from = o.to || zero; + el.to = o.from || original; + } else { + el.from = o.from || ( mode === "show" ? zero : original ); + el.to = o.to || ( mode === "hide" ? zero : original ); + } // Set scaling factor factor = { @@ -170,13 +180,13 @@ $.effects.effect.size = function( o, done ) { // Vertical props scaling if ( factor.from.y !== factor.to.y ) { - props = props.concat( cProps ); + props = props.concat( cProps ).concat( props2 ); el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from ); el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to ); } } - $.effects.save( el, restore ? props : props1 ); + $.effects.save( el, props ); el.show(); $.effects.createWrapper( el ); el.css( "overflow", "hidden" ).css( el.from ); @@ -197,7 +207,7 @@ $.effects.effect.size = function( o, done ) { // Add margins/font-size vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps); hProps = hProps.concat([ "marginLeft", "marginRight" ]); - props2 = props.concat(vProps).concat(hProps); + props2 = props0.concat(vProps).concat(hProps); el.find( "*[width]" ).each( function(){ var child = $( this ), @@ -254,7 +264,7 @@ $.effects.effect.size = function( o, done ) { if( mode === "hide" ) { el.hide(); } - $.effects.restore( el, restore ? props : props1 ); + $.effects.restore( el, props ); if ( !restore ) { // we need to calculate our new positioning based on the scaling |