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

Commit

Permalink
fix($animate): ensure that a timeStamp is created if not provided by …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
matsko committed Oct 12, 2013
1 parent 63c5334 commit cd216c4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/ngAnimate/animate.js
Original file line number Diff line number Diff line change
Expand Up @@ -787,15 +787,15 @@ angular.module('ngAnimate', ['ng'])
function onAnimationProgress(event) {
event.stopPropagation();
var ev = event.originalEvent || event;
var timeStamp = ev.$manualTimeStamp || ev.timeStamp || Date.now();
/* $manualTimeStamp is a mocked timeStamp value which is set
* within browserTrigger(). This is only here so that tests can
* mock animations properly. Real events fallback to event.timeStamp.
* We're checking to see if the timestamp surpasses the expected delay,
* but we're using elapsedTime instead of the timestamp on the 2nd
* mock animations properly. Real events fallback to event.timeStamp,
* or, if they don't, then a timeStamp is automatically created for them.
* We're checking to see if the timeStamp surpasses the expected delay,
* but we're using elapsedTime instead of the timeStamp on the 2nd
* pre-condition since animations sometimes close off early */
if((ev.$manualTimeStamp || ev.timeStamp) - startTime >= maxDelayTime &&
ev.elapsedTime >= maxDuration) {

if(Math.max(timeStamp - startTime, 0) >= maxDelayTime && ev.elapsedTime >= maxDuration) {
done();
}
}
Expand Down

0 comments on commit cd216c4

Please sign in to comment.