@@ -102,8 +102,9 @@ $.effects.effect.scale = function( o, done ) {
102
102
$ . effects . effect . size = function ( o , done ) {
103
103
104
104
// 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" ] ,
107
108
108
109
// Always restore
109
110
props1 = [ "position" , "top" , "bottom" , "left" , "right" , "overflow" , "opacity" ] ,
@@ -119,8 +120,12 @@ $.effects.effect.size = function( o, done ) {
119
120
restore = o . restore || mode !== "effect" ,
120
121
scale = o . scale || "both" ,
121
122
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
+ } ;
124
129
125
130
if ( mode === "show" ) {
126
131
el . show ( ) ;
@@ -132,8 +137,13 @@ $.effects.effect.size = function( o, done ) {
132
137
outerWidth : el . outerWidth ( )
133
138
} ;
134
139
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
+ }
137
147
138
148
// Set scaling factor
139
149
factor = {
@@ -170,13 +180,13 @@ $.effects.effect.size = function( o, done ) {
170
180
171
181
// Vertical props scaling
172
182
if ( factor . from . y !== factor . to . y ) {
173
- props = props . concat ( cProps ) ;
183
+ props = props . concat ( cProps ) . concat ( props2 ) ;
174
184
el . from = $ . effects . setTransition ( el , cProps , factor . from . y , el . from ) ;
175
185
el . to = $ . effects . setTransition ( el , cProps , factor . to . y , el . to ) ;
176
186
}
177
187
}
178
188
179
- $ . effects . save ( el , restore ? props : props1 ) ;
189
+ $ . effects . save ( el , props ) ;
180
190
el . show ( ) ;
181
191
$ . effects . createWrapper ( el ) ;
182
192
el . css ( "overflow" , "hidden" ) . css ( el . from ) ;
@@ -197,7 +207,7 @@ $.effects.effect.size = function( o, done ) {
197
207
// Add margins/font-size
198
208
vProps = vProps . concat ( [ "marginTop" , "marginBottom" ] ) . concat ( cProps ) ;
199
209
hProps = hProps . concat ( [ "marginLeft" , "marginRight" ] ) ;
200
- props2 = props . concat ( vProps ) . concat ( hProps ) ;
210
+ props2 = props0 . concat ( vProps ) . concat ( hProps ) ;
201
211
202
212
el . find ( "*[width]" ) . each ( function ( ) {
203
213
var child = $ ( this ) ,
@@ -254,7 +264,7 @@ $.effects.effect.size = function( o, done ) {
254
264
if ( mode === "hide" ) {
255
265
el . hide ( ) ;
256
266
}
257
- $ . effects . restore ( el , restore ? props : props1 ) ;
267
+ $ . effects . restore ( el , props ) ;
258
268
if ( ! restore ) {
259
269
260
270
// we need to calculate our new positioning based on the scaling
0 commit comments