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

Commit 90e424b

Browse files
committed
fix($animateCss): ensure that rAF waiting loop doesn't ignore pending items during a flush
Some animations may involve multiple stages of RAF requests before they are run. This issue may cause an animation never to fire since the rAF waiting queue may be modified during the flush stage and the code would only pay attention to its starting length. This fix makes the rAF flushing loop pay attention to the length with each iteration.
1 parent 8f819d2 commit 90e424b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/ngAnimate/animateCss.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -494,9 +494,12 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
494494
//WILL RESULT IN AN UNPREDICTABLE BUG THAT IS VERY HARD TO TRACK DOWN AND
495495
//WILL TAKE YEARS AWAY FROM YOUR LIFE.
496496
var width = bod.offsetWidth + 1;
497-
forEach(rafWaitQueue, function(cb) {
498-
cb(width);
499-
});
497+
498+
// we use a for loop to ensure that if the queue is changed
499+
// during this looping then it will consider new requests
500+
for (var i = 0; i < rafWaitQueue.length; i++) {
501+
rafWaitQueue[i](width);
502+
}
500503
rafWaitQueue.length = 0;
501504
});
502505
}

0 commit comments

Comments
 (0)