@@ -42,22 +42,21 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
42
42
} ) ;
43
43
}
44
44
45
- function hasAnimationClasses ( options , and ) {
46
- options = options || { } ;
47
- var a = ( options . addClass || '' ) . length > 0 ;
48
- var b = ( options . removeClass || '' ) . length > 0 ;
45
+ function hasAnimationClasses ( animation , and ) {
46
+ var a = ( animation . addClass || '' ) . length > 0 ;
47
+ var b = ( animation . removeClass || '' ) . length > 0 ;
49
48
return and ? a && b : a || b ;
50
49
}
51
50
52
51
rules . join . push ( function ( element , newAnimation , currentAnimation ) {
53
52
// if the new animation is class-based then we can just tack that on
54
- return ! newAnimation . structural && hasAnimationClasses ( newAnimation . options ) ;
53
+ return ! newAnimation . structural && hasAnimationClasses ( newAnimation ) ;
55
54
} ) ;
56
55
57
56
rules . skip . push ( function ( element , newAnimation , currentAnimation ) {
58
57
// there is no need to animate anything if no classes are being added and
59
58
// there is no structural animation that will be triggered
60
- return ! newAnimation . structural && ! hasAnimationClasses ( newAnimation . options ) ;
59
+ return ! newAnimation . structural && ! hasAnimationClasses ( newAnimation ) ;
61
60
} ) ;
62
61
63
62
rules . skip . push ( function ( element , newAnimation , currentAnimation ) {
@@ -83,19 +82,17 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
83
82
} ) ;
84
83
85
84
rules . cancel . push ( function ( element , newAnimation , currentAnimation ) {
86
-
87
-
88
- var nA = newAnimation . options . addClass ;
89
- var nR = newAnimation . options . removeClass ;
90
- var cA = currentAnimation . options . addClass ;
91
- var cR = currentAnimation . options . removeClass ;
85
+ var nA = newAnimation . addClass ;
86
+ var nR = newAnimation . removeClass ;
87
+ var cA = currentAnimation . addClass ;
88
+ var cR = currentAnimation . removeClass ;
92
89
93
90
// early detection to save the global CPU shortage :)
94
91
if ( ( isUndefined ( nA ) && isUndefined ( nR ) ) || ( isUndefined ( cA ) && isUndefined ( cR ) ) ) {
95
92
return false ;
96
93
}
97
94
98
- return ( hasMatchingClasses ( nA , cR ) ) || ( hasMatchingClasses ( nR , cA ) ) ;
95
+ return hasMatchingClasses ( nA , cR ) || hasMatchingClasses ( nR , cA ) ;
99
96
} ) ;
100
97
101
98
this . $get = [ '$$rAF' , '$rootScope' , '$rootElement' , '$document' , '$$HashMap' ,
@@ -167,8 +164,8 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
167
164
168
165
var applyAnimationClasses = applyAnimationClassesFactory ( $$jqLite ) ;
169
166
170
- function normalizeAnimationOptions ( element , options ) {
171
- return mergeAnimationOptions ( element , options , { } ) ;
167
+ function normalizeAnimationDetails ( element , animation ) {
168
+ return mergeAnimationDetails ( element , animation , { } ) ;
172
169
}
173
170
174
171
// IE9-11 has no method "contains" in SVG element and in Node.prototype. Bug #10259.
@@ -362,19 +359,27 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
362
359
structural : isStructural ,
363
360
element : element ,
364
361
event : event ,
362
+ addClass : options . addClass ,
363
+ removeClass : options . removeClass ,
365
364
close : close ,
366
365
options : options ,
367
366
runner : runner
368
367
} ;
369
368
369
+ if ( ! hasExistingAnimation ) {
370
+ // normalization in this case means that it removes redundant CSS classes that
371
+ // already exist (addClass) or do not exist (removeClass) on the element
372
+ normalizeAnimationDetails ( element , newAnimation ) ;
373
+ }
374
+
370
375
if ( hasExistingAnimation ) {
371
376
var skipAnimationFlag = isAllowed ( 'skip' , element , newAnimation , existingAnimation ) ;
372
377
if ( skipAnimationFlag ) {
373
378
if ( existingAnimation . state === RUNNING_STATE ) {
374
379
close ( ) ;
375
380
return runner ;
376
381
} else {
377
- mergeAnimationOptions ( element , existingAnimation . options , options ) ;
382
+ mergeAnimationDetails ( element , existingAnimation . options , options ) ;
378
383
return existingAnimation . runner ;
379
384
}
380
385
}
@@ -393,7 +398,8 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
393
398
existingAnimation . close ( ) ;
394
399
} else {
395
400
// this will merge the new animation options into existing animation options
396
- mergeAnimationOptions ( element , existingAnimation . options , newAnimation . options ) ;
401
+ mergeAnimationDetails ( element , existingAnimation , newAnimation ) ;
402
+
397
403
return existingAnimation . runner ;
398
404
}
399
405
} else {
@@ -403,23 +409,19 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
403
409
var joinAnimationFlag = isAllowed ( 'join' , element , newAnimation , existingAnimation ) ;
404
410
if ( joinAnimationFlag ) {
405
411
if ( existingAnimation . state === RUNNING_STATE ) {
406
- normalizeAnimationOptions ( element , options ) ;
412
+ normalizeAnimationDetails ( element , newAnimation ) ;
407
413
} else {
408
414
applyGeneratedPreparationClasses ( element , isStructural ? event : null , options ) ;
409
415
410
416
event = newAnimation . event = existingAnimation . event ;
411
- options = mergeAnimationOptions ( element , existingAnimation . options , newAnimation . options ) ;
417
+ options = mergeAnimationDetails ( element , existingAnimation , newAnimation ) ;
412
418
413
419
//we return the same runner since only the option values of this animation will
414
420
//be fed into the `existingAnimation`.
415
421
return existingAnimation . runner ;
416
422
}
417
423
}
418
424
}
419
- } else {
420
- // normalization in this case means that it removes redundant CSS classes that
421
- // already exist (addClass) or do not exist (removeClass) on the element
422
- normalizeAnimationOptions ( element , options ) ;
423
425
}
424
426
425
427
// when the options are merged and cleaned up we may end up not having to do
@@ -429,7 +431,7 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
429
431
if ( ! isValidAnimation ) {
430
432
// animate (from/to) can be quickly checked first, otherwise we check if any classes are present
431
433
isValidAnimation = ( newAnimation . event === 'animate' && Object . keys ( newAnimation . options . to || { } ) . length > 0 )
432
- || hasAnimationClasses ( newAnimation . options ) ;
434
+ || hasAnimationClasses ( newAnimation ) ;
433
435
}
434
436
435
437
if ( ! isValidAnimation ) {
@@ -459,7 +461,7 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
459
461
var isValidAnimation = parentElement . length > 0
460
462
&& ( animationDetails . event === 'animate'
461
463
|| animationDetails . structural
462
- || hasAnimationClasses ( animationDetails . options ) ) ;
464
+ || hasAnimationClasses ( animationDetails ) ) ;
463
465
464
466
// this means that the previous animation was cancelled
465
467
// even if the follow-up animation is the same event
@@ -491,7 +493,7 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
491
493
492
494
// this combined multiple class to addClass / removeClass into a setClass event
493
495
// so long as a structural event did not take over the animation
494
- event = ! animationDetails . structural && hasAnimationClasses ( animationDetails . options , true )
496
+ event = ! animationDetails . structural && hasAnimationClasses ( animationDetails , true )
495
497
? 'setClass'
496
498
: animationDetails . event ;
497
499
0 commit comments