Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit cd216c4

Browse files
committed
fix($animate): ensure that a timeStamp is created if not provided by the browser event
Firefox and (sometimes) Opera may not provide a timeStamp value in their event when passed to the event handler. This may cause animations not to close properly. This fix will automatically create a timeStamp value for the event in this situation when missing. Closes #3053
1 parent 63c5334 commit cd216c4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/ngAnimate/animate.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -787,15 +787,15 @@ angular.module('ngAnimate', ['ng'])
787787
function onAnimationProgress(event) {
788788
event.stopPropagation();
789789
var ev = event.originalEvent || event;
790+
var timeStamp = ev.$manualTimeStamp || ev.timeStamp || Date.now();
790791
/* $manualTimeStamp is a mocked timeStamp value which is set
791792
* within browserTrigger(). This is only here so that tests can
792-
* mock animations properly. Real events fallback to event.timeStamp.
793-
* We're checking to see if the timestamp surpasses the expected delay,
794-
* but we're using elapsedTime instead of the timestamp on the 2nd
793+
* mock animations properly. Real events fallback to event.timeStamp,
794+
* or, if they don't, then a timeStamp is automatically created for them.
795+
* We're checking to see if the timeStamp surpasses the expected delay,
796+
* but we're using elapsedTime instead of the timeStamp on the 2nd
795797
* pre-condition since animations sometimes close off early */
796-
if((ev.$manualTimeStamp || ev.timeStamp) - startTime >= maxDelayTime &&
797-
ev.elapsedTime >= maxDuration) {
798-
798+
if(Math.max(timeStamp - startTime, 0) >= maxDelayTime && ev.elapsedTime >= maxDuration) {
799799
done();
800800
}
801801
}

0 commit comments

Comments
 (0)