@@ -248,6 +248,28 @@ angular.module('ngAnimate', ['ng'])
248
248
* Please visit the {@link ngAnimate `ngAnimate`} module overview page learn more about how to use animations in your application.
249
249
*
250
250
*/
251
+ . factory ( '$$animateReflow' , [ '$window' , '$timeout' , function ( $window , $timeout ) {
252
+ var requestAnimationFrame = $window . requestAnimationFrame ||
253
+ $window . mozRequestAnimationFrame ||
254
+ $window . webkitRequestAnimationFrame ||
255
+ function ( fn ) {
256
+ return $timeout ( fn , 10 , false ) ;
257
+ } ;
258
+
259
+ var cancelAnimationFrame = $window . cancelAnimationFrame ||
260
+ $window . mozCancelAnimationFrame ||
261
+ $window . webkitCancelAnimationFrame ||
262
+ function ( timer ) {
263
+ return $timeout . cancel ( timer ) ;
264
+ } ;
265
+ return function ( fn ) {
266
+ var id = requestAnimationFrame ( fn ) ;
267
+ return function ( ) {
268
+ cancelAnimationFrame ( id ) ;
269
+ } ;
270
+ } ;
271
+ } ] )
272
+
251
273
. config ( [ '$provide' , '$animateProvider' , function ( $provide , $animateProvider ) {
252
274
var noop = angular . noop ;
253
275
var forEach = angular . forEach ;
@@ -872,7 +894,8 @@ angular.module('ngAnimate', ['ng'])
872
894
}
873
895
} ] ) ;
874
896
875
- $animateProvider . register ( '' , [ '$window' , '$sniffer' , '$timeout' , function ( $window , $sniffer , $timeout ) {
897
+ $animateProvider . register ( '' , [ '$window' , '$sniffer' , '$timeout' , '$$animateReflow' ,
898
+ function ( $window , $sniffer , $timeout , $$animateReflow ) {
876
899
// Detect proper transitionend/animationend event names.
877
900
var CSS_PREFIX = '' , TRANSITION_PROP , TRANSITIONEND_EVENT , ANIMATION_PROP , ANIMATIONEND_EVENT ;
878
901
@@ -917,11 +940,13 @@ angular.module('ngAnimate', ['ng'])
917
940
var parentCounter = 0 ;
918
941
var animationReflowQueue = [ ] ;
919
942
var animationElementQueue = [ ] ;
920
- var animationTimer ;
943
+ var cancelAnimationReflow ;
921
944
var closingAnimationTime = 0 ;
922
945
var timeOut = false ;
923
946
function afterReflow ( element , callback ) {
924
- $timeout . cancel ( animationTimer ) ;
947
+ if ( cancelAnimationReflow ) {
948
+ cancelAnimationReflow ( ) ;
949
+ }
925
950
926
951
animationReflowQueue . push ( callback ) ;
927
952
@@ -942,7 +967,7 @@ angular.module('ngAnimate', ['ng'])
942
967
//a follow-up animation is midway in its animation
943
968
elementData . animationCount = animationCounter ;
944
969
945
- animationTimer = $timeout ( function ( ) {
970
+ cancelAnimationReflow = $$animateReflow ( function ( ) {
946
971
forEach ( animationReflowQueue , function ( fn ) {
947
972
fn ( ) ;
948
973
} ) ;
@@ -963,11 +988,11 @@ angular.module('ngAnimate', ['ng'])
963
988
964
989
animationReflowQueue = [ ] ;
965
990
animationElementQueue = [ ] ;
966
- animationTimer = null ;
991
+ cancelAnimationReflow = null ;
967
992
lookupCache = { } ;
968
993
closingAnimationTime = 0 ;
969
994
animationCounter ++ ;
970
- } , 10 , false ) ;
995
+ } ) ;
971
996
}
972
997
973
998
function closeAllAnimations ( elements , count ) {
0 commit comments