@@ -42,22 +42,21 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
} ) ;
}
function hasAnimationClasses ( options , and ) {
options = options || { } ;
var a = ( options . addClass || '' ) . length > 0 ;
var b = ( options . removeClass || '' ) . length > 0 ;
function hasAnimationClasses ( animation , and ) {
var a = ( animation . addClass || '' ) . length > 0 ;
var b = ( animation . removeClass || '' ) . length > 0 ;
return and ? a && b : a || b ;
}
rules . join . push ( function ( element , newAnimation , currentAnimation ) {
// if the new animation is class-based then we can just tack that on
return !newAnimation . structural && hasAnimationClasses ( newAnimation . options ) ;
return !newAnimation . structural && hasAnimationClasses ( newAnimation ) ;
} ) ;
rules . skip . push ( function ( element , newAnimation , currentAnimation ) {
// there is no need to animate anything if no classes are being added and
// there is no structural animation that will be triggered
return !newAnimation . structural && !hasAnimationClasses ( newAnimation . options ) ;
return !newAnimation . structural && !hasAnimationClasses ( newAnimation ) ;
} ) ;
rules . skip . push ( function ( element , newAnimation , currentAnimation ) {
@@ -83,19 +82,17 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
} ) ;
rules . cancel . push ( function ( element , newAnimation , currentAnimation ) {
var nA = newAnimation . options . addClass ;
var nR = newAnimation . options . removeClass ;
var cA = currentAnimation . options . addClass ;
var cR = currentAnimation . options . removeClass ;
var nA = newAnimation . addClass ;
var nR = newAnimation . removeClass ;
var cA = currentAnimation . addClass ;
var cR = currentAnimation . removeClass ;
// early detection to save the global CPU shortage :)
if ( ( isUndefined ( nA ) && isUndefined ( nR ) ) || ( isUndefined ( cA ) && isUndefined ( cR ) ) ) {
return false ;
}
return ( hasMatchingClasses ( nA , cR ) ) || ( hasMatchingClasses ( nR , cA ) ) ;
return hasMatchingClasses ( nA , cR ) || hasMatchingClasses ( nR , cA ) ;
} ) ;
this . $get = [ '$$rAF' , '$rootScope' , '$rootElement' , '$document' , '$$HashMap' ,
@@ -167,8 +164,8 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
var applyAnimationClasses = applyAnimationClassesFactory ( $$jqLite ) ;
function normalizeAnimationOptions ( element , options ) {
return mergeAnimationOptions ( element , options , { } ) ;
function normalizeAnimationDetails ( element , animation ) {
return mergeAnimationDetails ( element , animation , { } ) ;
}
// IE9-11 has no method "contains" in SVG element and in Node.prototype. Bug #10259.
@@ -362,6 +359,8 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
structural : isStructural ,
element : element ,
event : event ,
addClass : options . addClass ,
removeClass : options . removeClass ,
close : close ,
options : options ,
runner : runner
@@ -374,11 +373,10 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
close ( ) ;
return runner ;
} else {
mergeAnimationOptions ( element , existingAnimation . options , options ) ;
mergeAnimationDetails ( element , existingAnimation , newAnimation ) ;
return existingAnimation . runner ;
}
}
var cancelAnimationFlag = isAllowed ( 'cancel' , element , newAnimation , existingAnimation ) ;
if ( cancelAnimationFlag ) {
if ( existingAnimation . state === RUNNING_STATE ) {
@@ -393,7 +391,8 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
existingAnimation . close ( ) ;
} else {
// this will merge the new animation options into existing animation options
mergeAnimationOptions ( element , existingAnimation . options , newAnimation . options ) ;
mergeAnimationDetails ( element , existingAnimation , newAnimation ) ;
return existingAnimation . runner ;
}
} else {
@@ -403,12 +402,12 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
var joinAnimationFlag = isAllowed ( 'join' , element , newAnimation , existingAnimation ) ;
if ( joinAnimationFlag ) {
if ( existingAnimation . state === RUNNING_STATE ) {
normalizeAnimationOptions ( element , options ) ;
normalizeAnimationDetails ( element , newAnimation ) ;
} else {
applyGeneratedPreparationClasses ( element , isStructural ? event : null, options ) ;
event = newAnimation . event = existingAnimation . event ;
options = mergeAnimationOptions ( element , existingAnimation . options , newAnimation . options ) ;
options = mergeAnimationDetails ( element , existingAnimation , newAnimation ) ;
//we return the same runner since only the option values of this animation will
//be fed into the `existingAnimation`.
@@ -419,7 +418,7 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
} else {
// normalization in this case means that it removes redundant CSS classes that
// already exist (addClass) or do not exist (removeClass) on the element
normalizeAnimationOptions ( element , options ) ;
normalizeAnimationDetails ( element , newAnimation ) ;
}
// when the options are merged and cleaned up we may end up not having to do
@@ -429,7 +428,7 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
if ( !isValidAnimation ) {
// animate (from/to) can be quickly checked first, otherwise we check if any classes are present
isValidAnimation = ( newAnimation . event === 'animate' && Object . keys ( newAnimation . options . to || { } ) . length > 0 )
|| hasAnimationClasses ( newAnimation . options ) ;
|| hasAnimationClasses ( newAnimation ) ;
}
if ( !isValidAnimation ) {
@@ -459,7 +458,7 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
var isValidAnimation = parentElement . length > 0
&& ( animationDetails . event === 'animate'
|| animationDetails . structural
|| hasAnimationClasses ( animationDetails . options ) ) ;
|| hasAnimationClasses ( animationDetails ) ) ;
// this means that the previous animation was cancelled
// even if the follow-up animation is the same event
@@ -491,7 +490,7 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
// this combined multiple class to addClass / removeClass into a setClass event
// so long as a structural event did not take over the animation
event = !animationDetails . structural && hasAnimationClasses ( animationDetails . options , true )
event = !animationDetails . structural && hasAnimationClasses ( animationDetails , true )
? 'setClass'
: animationDetails . event ;