fix($animate): ensure all animated elements are taken care of during the closing timeout

Closes #6395
This commit is contained in:
Matias Niemelä
2014-02-24 14:47:12 -05:00
parent 332e935048
commit 99720fb5ab
2 changed files with 52 additions and 4 deletions

View File

@@ -1063,6 +1063,15 @@ angular.module('ngAnimate', ['ng'])
var closingTimestamp = 0;
var animationElementQueue = [];
function animationCloseHandler(element, totalTime) {
var node = extractElementNode(element);
element = angular.element(node);
//this item will be garbage collected by the closing
//animation timeout
animationElementQueue.push(element);
//but it may not need to cancel out the existing timeout
//if the timestamp is less than the previous one
var futureTimestamp = Date.now() + (totalTime * 1000);
if(futureTimestamp <= closingTimestamp) {
return;
@@ -1070,10 +1079,6 @@ angular.module('ngAnimate', ['ng'])
$timeout.cancel(closingTimer);
var node = extractElementNode(element);
element = angular.element(node);
animationElementQueue.push(element);
closingTimestamp = futureTimestamp;
closingTimer = $timeout(function() {
closeAllAnimations(animationElementQueue);