diff options
| author | Matias Niemelä | 2013-10-12 12:35:34 -0400 |
|---|---|---|
| committer | Matias Niemelä | 2013-10-12 19:52:47 -0400 |
| commit | cd216c4c30adfebb3ef633f18fab2d98e8c52ebc (patch) | |
| tree | f2e57be6b76177a803e340e927fadb8d9451640e /src | |
| parent | 63c5334c84b7269428c710226764d1f08a36e0d4 (diff) | |
| download | angular.js-cd216c4c30adfebb3ef633f18fab2d98e8c52ebc.tar.bz2 | |
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/ngAnimate/animate.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/ngAnimate/animate.js b/src/ngAnimate/animate.js index 18cd1c20..38f8bcb9 100644 --- a/src/ngAnimate/animate.js +++ b/src/ngAnimate/animate.js @@ -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(); } } |
