Skip to content

Commit 5f9d5c5

Browse files
kzysgnarf
authored andcommitted
Effects (size): Adjusting behavior of toggled size effects - See jquerygh-203 - Partial Fix for #7041
1 parent 721a4b4 commit 5f9d5c5

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

ui/jquery.ui.effect-scale.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ $.effects.effect.scale = function( o, done ) {
102102
$.effects.effect.size = function( o, done ) {
103103

104104
// Create element
105-
var el = $( this ),
106-
props = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
105+
var original, baseline, factor,
106+
el = $( this ),
107+
props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
107108

108109
// Always restore
109110
props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
@@ -119,8 +120,12 @@ $.effects.effect.size = function( o, done ) {
119120
restore = o.restore || mode !== "effect",
120121
scale = o.scale || "both",
121122
origin = o.origin || [ "middle", "center" ],
122-
original, baseline, factor,
123-
position = el.css( "position" );
123+
position = el.css( "position" ),
124+
props = restore ? props0 : props1,
125+
zero = {
126+
height: 0,
127+
width: 0
128+
};
124129

125130
if ( mode === "show" ) {
126131
el.show();
@@ -132,8 +137,13 @@ $.effects.effect.size = function( o, done ) {
132137
outerWidth: el.outerWidth()
133138
};
134139

135-
el.from = o.from || original;
136-
el.to = o.to || original;
140+
if ( o.mode === "toggle" && mode === "show" ) {
141+
el.from = o.to || zero;
142+
el.to = o.from || original;
143+
} else {
144+
el.from = o.from || ( mode === "show" ? zero : original );
145+
el.to = o.to || ( mode === "hide" ? zero : original );
146+
}
137147

138148
// Set scaling factor
139149
factor = {
@@ -170,13 +180,13 @@ $.effects.effect.size = function( o, done ) {
170180

171181
// Vertical props scaling
172182
if ( factor.from.y !== factor.to.y ) {
173-
props = props.concat( cProps );
183+
props = props.concat( cProps ).concat( props2 );
174184
el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
175185
el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
176186
}
177187
}
178188

179-
$.effects.save( el, restore ? props : props1 );
189+
$.effects.save( el, props );
180190
el.show();
181191
$.effects.createWrapper( el );
182192
el.css( "overflow", "hidden" ).css( el.from );
@@ -197,7 +207,7 @@ $.effects.effect.size = function( o, done ) {
197207
// Add margins/font-size
198208
vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
199209
hProps = hProps.concat([ "marginLeft", "marginRight" ]);
200-
props2 = props.concat(vProps).concat(hProps);
210+
props2 = props0.concat(vProps).concat(hProps);
201211

202212
el.find( "*[width]" ).each( function(){
203213
var child = $( this ),
@@ -254,7 +264,7 @@ $.effects.effect.size = function( o, done ) {
254264
if( mode === "hide" ) {
255265
el.hide();
256266
}
257-
$.effects.restore( el, restore ? props : props1 );
267+
$.effects.restore( el, props );
258268
if ( !restore ) {
259269

260270
// we need to calculate our new positioning based on the scaling

0 commit comments

Comments
 (0)