@@ -232,33 +232,41 @@ $.effects.animateClass = function(value, duration, easing, callback) {
232
232
}
233
233
234
234
return this . each ( function ( ) {
235
+ $ . queue ( this , 'fx' , function ( ) {
236
+ var that = $ ( this ) ,
237
+ originalStyleAttr = that . attr ( 'style' ) || ' ' ,
238
+ originalStyle = filterStyles ( getElementStyles . call ( this ) ) ,
239
+ newStyle ,
240
+ className = that . attr ( 'className' ) ;
235
241
236
- var that = $ ( this ) ,
237
- originalStyleAttr = that . attr ( 'style' ) || ' ' ,
238
- originalStyle = filterStyles ( getElementStyles . call ( this ) ) ,
239
- newStyle ,
240
- className = that . attr ( 'className' ) ;
241
-
242
- $ . each ( classAnimationActions , function ( i , action ) {
243
- if ( value [ action ] ) {
244
- that [ action + 'Class' ] ( value [ action ] ) ;
245
- }
246
- } ) ;
247
- newStyle = filterStyles ( getElementStyles . call ( this ) ) ;
248
- that . attr ( 'className' , className ) ;
249
-
250
- that . animate ( styleDifference ( originalStyle , newStyle ) , duration , easing , function ( ) {
251
242
$ . each ( classAnimationActions , function ( i , action ) {
252
- if ( value [ action ] ) { that [ action + 'Class' ] ( value [ action ] ) ; }
243
+ if ( value [ action ] ) {
244
+ that [ action + 'Class' ] ( value [ action ] ) ;
245
+ }
253
246
} ) ;
254
- // work around bug in IE by clearing the cssText before setting it
255
- if ( typeof that . attr ( 'style' ) == 'object' ) {
256
- that . attr ( 'style' ) . cssText = '' ;
257
- that . attr ( 'style' ) . cssText = originalStyleAttr ;
258
- } else {
259
- that . attr ( 'style' , originalStyleAttr ) ;
260
- }
261
- if ( callback ) { callback . apply ( this , arguments ) ; }
247
+ newStyle = filterStyles ( getElementStyles . call ( this ) ) ;
248
+ that . attr ( 'className' , className ) ;
249
+
250
+ that . animate ( styleDifference ( originalStyle , newStyle ) , duration , easing , function ( ) {
251
+ $ . each ( classAnimationActions , function ( i , action ) {
252
+ if ( value [ action ] ) { that [ action + 'Class' ] ( value [ action ] ) ; }
253
+ } ) ;
254
+ // work around bug in IE by clearing the cssText before setting it
255
+ if ( typeof that . attr ( 'style' ) == 'object' ) {
256
+ that . attr ( 'style' ) . cssText = '' ;
257
+ that . attr ( 'style' ) . cssText = originalStyleAttr ;
258
+ } else {
259
+ that . attr ( 'style' , originalStyleAttr ) ;
260
+ }
261
+ if ( callback ) { callback . apply ( this , arguments ) ; }
262
+ } ) ;
263
+
264
+ // $.animate adds a function to the end of the queue
265
+ // but we want it at the front
266
+ var queue = $ . queue ( this ) ,
267
+ anim = queue . splice ( queue . length - 1 , 1 ) [ 0 ] ;
268
+ queue . splice ( 1 , 0 , anim ) ;
269
+ $ . dequeue ( this ) ;
262
270
} ) ;
263
271
} ) ;
264
272
} ;
0 commit comments