@@ -930,8 +930,12 @@ angular.module('ngAnimate', ['ng'])
930930 animationElementQueue . push ( element ) ;
931931
932932 var elementData = element . data ( NG_ANIMATE_CSS_DATA_KEY ) ;
933- closingAnimationTime = Math . max ( closingAnimationTime ,
934- ( elementData . maxDelay + elementData . maxDuration ) * CLOSING_TIME_BUFFER * ONE_SECOND ) ;
933+
934+ var stagger = elementData . stagger ;
935+ var staggerTime = elementData . itemIndex * ( Math . max ( stagger . animationDelay , stagger . transitionDelay ) || 0 ) ;
936+
937+ var animationTime = ( elementData . maxDelay + elementData . maxDuration ) * CLOSING_TIME_BUFFER ;
938+ closingAnimationTime = Math . max ( closingAnimationTime , ( staggerTime + animationTime ) * ONE_SECOND ) ;
935939
936940 //by placing a counter we can avoid an accidental
937941 //race condition which may close an animation when
@@ -1058,9 +1062,9 @@ angular.module('ngAnimate', ['ng'])
10581062 var cacheKey = getCacheKey ( element ) ;
10591063 var eventCacheKey = cacheKey + ' ' + className ;
10601064 var stagger = { } ;
1061- var ii = lookupCache [ eventCacheKey ] ? ++ lookupCache [ eventCacheKey ] . total : 0 ;
1065+ var itemIndex = lookupCache [ eventCacheKey ] ? ++ lookupCache [ eventCacheKey ] . total : 0 ;
10621066
1063- if ( ii > 0 ) {
1067+ if ( itemIndex > 0 ) {
10641068 var staggerClassName = className + '-stagger' ;
10651069 var staggerCacheKey = cacheKey + ' ' + staggerClassName ;
10661070 var applyClasses = ! lookupCache [ staggerCacheKey ] ;
@@ -1113,7 +1117,7 @@ angular.module('ngAnimate', ['ng'])
11131117 classes : className + ' ' + activeClassName ,
11141118 timings : timings ,
11151119 stagger : stagger ,
1116- ii : ii
1120+ itemIndex : itemIndex
11171121 } ) ;
11181122
11191123 return true ;
@@ -1158,7 +1162,7 @@ angular.module('ngAnimate', ['ng'])
11581162 var maxDelayTime = Math . max ( timings . transitionDelay , timings . animationDelay ) * ONE_SECOND ;
11591163 var startTime = Date . now ( ) ;
11601164 var css3AnimationEvents = ANIMATIONEND_EVENT + ' ' + TRANSITIONEND_EVENT ;
1161- var ii = elementData . ii ;
1165+ var itemIndex = elementData . itemIndex ;
11621166
11631167 var style = '' , appliedStyles = [ ] ;
11641168 if ( timings . transitionDuration > 0 ) {
@@ -1171,17 +1175,17 @@ angular.module('ngAnimate', ['ng'])
11711175 }
11721176 }
11731177
1174- if ( ii > 0 ) {
1178+ if ( itemIndex > 0 ) {
11751179 if ( stagger . transitionDelay > 0 && stagger . transitionDuration === 0 ) {
11761180 var delayStyle = timings . transitionDelayStyle ;
11771181 style += CSS_PREFIX + 'transition-delay: ' +
1178- prepareStaggerDelay ( delayStyle , stagger . transitionDelay , ii ) + '; ' ;
1182+ prepareStaggerDelay ( delayStyle , stagger . transitionDelay , itemIndex ) + '; ' ;
11791183 appliedStyles . push ( CSS_PREFIX + 'transition-delay' ) ;
11801184 }
11811185
11821186 if ( stagger . animationDelay > 0 && stagger . animationDuration === 0 ) {
11831187 style += CSS_PREFIX + 'animation-delay: ' +
1184- prepareStaggerDelay ( timings . animationDelayStyle , stagger . animationDelay , ii ) + '; ' ;
1188+ prepareStaggerDelay ( timings . animationDelayStyle , stagger . animationDelay , itemIndex ) + '; ' ;
11851189 appliedStyles . push ( CSS_PREFIX + 'animation-delay' ) ;
11861190 }
11871191 }
0 commit comments