@@ -424,7 +424,7 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
424424 var KEY = "$$ngAnimateParentKey" ;
425425 var parentNode = node . parentNode ;
426426 var parentID = parentNode [ KEY ] || ( parentNode [ KEY ] = ++ parentCounter ) ;
427- return parentID + '-' + node . getAttribute ( 'class' ) + '-' + extraClasses ;
427+ return parentID + '-' + ( node . getAttribute ( 'class' ) || '' ) + '-' + ( extraClasses || '' ) ;
428428 }
429429
430430 function computeCachedCssStyles ( node , className , cacheKey , properties ) {
@@ -472,6 +472,11 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
472472 return stagger || { } ;
473473 }
474474
475+ function flushGCSCache ( ) {
476+ gcsLookup . flush ( ) ;
477+ gcsStaggerLookup . flush ( ) ;
478+ }
479+
475480 var bod = $document [ 0 ] . body ;
476481 var cancelLastRAFRequest ;
477482 var rafWaitQueue = [ ] ;
@@ -482,8 +487,7 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
482487 rafWaitQueue . push ( callback ) ;
483488 cancelLastRAFRequest = $$rAF ( function ( ) {
484489 cancelLastRAFRequest = null ;
485- gcsLookup . flush ( ) ;
486- gcsStaggerLookup . flush ( ) ;
490+ flushGCSCache ( ) ;
487491
488492 //the line below will force the browser to perform a repaint so
489493 //that all the animated elements within the animation frame will
@@ -514,7 +518,7 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
514518 ? Math . max ( aD , tD )
515519 : ( aD || tD ) ;
516520 timings . maxDuration = Math . max (
517- timings . animationDuration * timings . animationIterationCount ,
521+ ( timings . animationDuration * timings . animationIterationCount ) || 0 ,
518522 timings . transitionDuration ) ;
519523
520524 return timings ;
@@ -525,7 +529,7 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
525529 options = prepareAnimationOptions ( options ) ;
526530
527531 var temporaryStyles = [ ] ;
528- var classes = element . attr ( 'class' ) ;
532+ var classes = element . attr ( 'class' ) || '' ;
529533 var styles = packageStyles ( options ) ;
530534 var animationClosed ;
531535 var animationPaused ;
@@ -649,7 +653,7 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
649653
650654 var timings = computeTimings ( node , fullClassName , cacheKey ) ;
651655 var relativeDelay = timings . maxDelay ;
652- maxDelay = Math . max ( relativeDelay , 0 ) ;
656+ maxDelay = Math . max ( relativeDelay || 0 , 0 ) ;
653657 maxDuration = timings . maxDuration ;
654658
655659 var flags = { } ;
@@ -715,6 +719,11 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
715719 start : function ( ) {
716720 if ( animationClosed ) return ;
717721
722+ // the code below will wait until the first RAF has passed. By waiting
723+ // we allow multiple similar animations to be grouped together to allow
724+ // for stagger calculations. This waiting phase is known as the quiet
725+ // phase and any code that runs after is known as "post-quiet" code.
726+
718727 runnerHost = {
719728 end : endFn ,
720729 cancel : cancelFn ,
@@ -765,6 +774,10 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
765774 applyAnimationClasses ( element , options ) ;
766775 applyAnimationStyles ( element , options ) ;
767776
777+ // we need to clear the cache since the post-quiet state may add and remove CSS
778+ // classes which contain follow-up animation data which will be cached.
779+ $$rAF ( flushGCSCache ) ;
780+
768781 // the reason why we have this option is to allow a synchronous closing callback
769782 // that is fired as SOON as the animation ends (when the CSS is removed) or if
770783 // the animation never takes off at all. A good example is a leave animation since
@@ -860,7 +873,7 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
860873
861874 timings = computeTimings ( node , fullClassName , cacheKey ) ;
862875 relativeDelay = timings . maxDelay ;
863- maxDelay = Math . max ( relativeDelay , 0 ) ;
876+ maxDelay = Math . max ( relativeDelay || 0 , 0 ) ;
864877 maxDuration = timings . maxDuration ;
865878
866879 if ( maxDuration === 0 ) {
@@ -877,7 +890,7 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
877890 ? parseFloat ( options . delay )
878891 : relativeDelay ;
879892
880- maxDelay = Math . max ( relativeDelay , 0 ) ;
893+ maxDelay = Math . max ( relativeDelay || 0 , 0 ) ;
881894
882895 var delayStyle ;
883896 if ( flags . applyTransitionDelay ) {
0 commit comments