@@ -600,40 +600,43 @@ angular.module('ngAnimate', ['ng'])
600
600
element . addClass ( className ) ;
601
601
602
602
//we want all the styles defined before and after
603
- var transitionTime = 0 ,
604
- animationTime = 0 ;
603
+ var transitionDuration = 0 ,
604
+ animationDuration = 0 ,
605
+ transitionDelay = 0 ,
606
+ animationDelay = 0 ;
605
607
forEach ( element , function ( element ) {
606
608
if ( element . nodeType == ELEMENT_NODE ) {
607
609
var elementStyles = $window . getComputedStyle ( element ) || { } ;
608
610
609
- var transitionDelay = parseMaxTime ( elementStyles [ transitionProp + delayKey ] ) ;
611
+ transitionDelay = Math . max ( parseMaxTime ( elementStyles [ transitionProp + delayKey ] ) , transitionDelay ) ;
610
612
611
- var animationDelay = parseMaxTime ( elementStyles [ animationProp + delayKey ] ) ;
613
+ animationDelay = Math . max ( parseMaxTime ( elementStyles [ animationProp + delayKey ] ) , animationDelay ) ;
612
614
613
- var transitionDuration = parseMaxTime ( elementStyles [ transitionProp + durationKey ] ) ;
615
+ transitionDuration = Math . max ( parseMaxTime ( elementStyles [ transitionProp + durationKey ] ) , transitionDuration ) ;
614
616
615
- var animationDuration = parseMaxTime ( elementStyles [ animationProp + durationKey ] ) ;
617
+ var aDuration = parseMaxTime ( elementStyles [ animationProp + durationKey ] ) ;
616
618
617
- if ( animationDuration > 0 ) {
618
- animationDuration *= parseInt ( elementStyles [ animationProp + animationIterationCountKey ] ) || 1 ;
619
+ if ( aDuration > 0 ) {
620
+ aDuration *= parseInt ( elementStyles [ animationProp + animationIterationCountKey ] ) || 1 ;
619
621
}
620
622
621
- transitionTime = Math . max ( transitionDelay + transitionDuration , transitionTime ) ;
622
- animationTime = Math . max ( animationDelay + animationDuration , animationTime ) ;
623
+ animationDuration = Math . max ( aDuration , animationDuration ) ;
623
624
}
624
625
} ) ;
625
626
626
627
/* there is no point in performing a reflow if the animation
627
628
timeout is empty (this would cause a flicker bug normally
628
- in the page */
629
- var maxTime = Math . max ( transitionTime , animationTime ) * 1000 ;
630
- if ( maxTime > 0 ) {
631
- var node = element [ 0 ] ,
632
- startTime = Date . now ( ) ;
629
+ in the page. There is also no point in performing an animation
630
+ that only has a delay and no duration */
631
+ var maxDuration = Math . max ( transitionDuration , animationDuration ) ;
632
+ if ( maxDuration > 0 ) {
633
+ var maxDelayTime = Math . max ( transitionDelay , animationDelay ) * 1000 ,
634
+ startTime = Date . now ( ) ,
635
+ node = element [ 0 ] ;
633
636
634
637
//temporarily disable the transition so that the enter styles
635
638
//don't animate twice (this is here to avoid a bug in Chrome/FF).
636
- if ( transitionTime > 0 ) {
639
+ if ( transitionDuration > 0 ) {
637
640
node . style [ transitionProp + propertyKey ] = 'none' ;
638
641
}
639
642
@@ -644,7 +647,7 @@ angular.module('ngAnimate', ['ng'])
644
647
645
648
// This triggers a reflow which allows for the transition animation to kick in.
646
649
element . prop ( 'clientWidth' ) ;
647
- if ( transitionTime > 0 ) {
650
+ if ( transitionDuration > 0 ) {
648
651
node . style [ transitionProp + propertyKey ] = '' ;
649
652
}
650
653
element . addClass ( activeClassName ) ;
@@ -678,8 +681,13 @@ angular.module('ngAnimate', ['ng'])
678
681
var ev = event . originalEvent || event ;
679
682
/* $manualTimeStamp is a mocked timeStamp value which is set
680
683
* within browserTrigger(). This is only here so that tests can
681
- * mock animations properly. Real events fallback to event.timeStamp. */
682
- if ( ( ev . $manualTimeStamp || ev . timeStamp ) - startTime >= maxTime ) {
684
+ * mock animations properly. Real events fallback to event.timeStamp.
685
+ * We're checking to see if the timestamp surpasses the expected delay,
686
+ * but we're using elapsedTime instead of the timestamp on the 2nd
687
+ * pre-condition since animations sometimes close off early */
688
+ if ( ( ev . $manualTimeStamp || ev . timeStamp ) - startTime >= maxDelayTime &&
689
+ ev . elapsedTime >= maxDuration ) {
690
+
683
691
done ( ) ;
684
692
}
685
693
}
0 commit comments