@@ -930,8 +930,12 @@ angular.module('ngAnimate', ['ng'])
930
930
animationElementQueue . push ( element ) ;
931
931
932
932
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 ) ;
935
939
936
940
//by placing a counter we can avoid an accidental
937
941
//race condition which may close an animation when
@@ -1058,9 +1062,9 @@ angular.module('ngAnimate', ['ng'])
1058
1062
var cacheKey = getCacheKey ( element ) ;
1059
1063
var eventCacheKey = cacheKey + ' ' + className ;
1060
1064
var stagger = { } ;
1061
- var ii = lookupCache [ eventCacheKey ] ? ++ lookupCache [ eventCacheKey ] . total : 0 ;
1065
+ var itemIndex = lookupCache [ eventCacheKey ] ? ++ lookupCache [ eventCacheKey ] . total : 0 ;
1062
1066
1063
- if ( ii > 0 ) {
1067
+ if ( itemIndex > 0 ) {
1064
1068
var staggerClassName = className + '-stagger' ;
1065
1069
var staggerCacheKey = cacheKey + ' ' + staggerClassName ;
1066
1070
var applyClasses = ! lookupCache [ staggerCacheKey ] ;
@@ -1113,7 +1117,7 @@ angular.module('ngAnimate', ['ng'])
1113
1117
classes : className + ' ' + activeClassName ,
1114
1118
timings : timings ,
1115
1119
stagger : stagger ,
1116
- ii : ii
1120
+ itemIndex : itemIndex
1117
1121
} ) ;
1118
1122
1119
1123
return true ;
@@ -1158,7 +1162,7 @@ angular.module('ngAnimate', ['ng'])
1158
1162
var maxDelayTime = Math . max ( timings . transitionDelay , timings . animationDelay ) * ONE_SECOND ;
1159
1163
var startTime = Date . now ( ) ;
1160
1164
var css3AnimationEvents = ANIMATIONEND_EVENT + ' ' + TRANSITIONEND_EVENT ;
1161
- var ii = elementData . ii ;
1165
+ var itemIndex = elementData . itemIndex ;
1162
1166
1163
1167
var style = '' , appliedStyles = [ ] ;
1164
1168
if ( timings . transitionDuration > 0 ) {
@@ -1171,17 +1175,17 @@ angular.module('ngAnimate', ['ng'])
1171
1175
}
1172
1176
}
1173
1177
1174
- if ( ii > 0 ) {
1178
+ if ( itemIndex > 0 ) {
1175
1179
if ( stagger . transitionDelay > 0 && stagger . transitionDuration === 0 ) {
1176
1180
var delayStyle = timings . transitionDelayStyle ;
1177
1181
style += CSS_PREFIX + 'transition-delay: ' +
1178
- prepareStaggerDelay ( delayStyle , stagger . transitionDelay , ii ) + '; ' ;
1182
+ prepareStaggerDelay ( delayStyle , stagger . transitionDelay , itemIndex ) + '; ' ;
1179
1183
appliedStyles . push ( CSS_PREFIX + 'transition-delay' ) ;
1180
1184
}
1181
1185
1182
1186
if ( stagger . animationDelay > 0 && stagger . animationDuration === 0 ) {
1183
1187
style += CSS_PREFIX + 'animation-delay: ' +
1184
- prepareStaggerDelay ( timings . animationDelayStyle , stagger . animationDelay , ii ) + '; ' ;
1188
+ prepareStaggerDelay ( timings . animationDelayStyle , stagger . animationDelay , itemIndex ) + '; ' ;
1185
1189
appliedStyles . push ( CSS_PREFIX + 'animation-delay' ) ;
1186
1190
}
1187
1191
}
0 commit comments