@@ -19,8 +19,8 @@ var $$AnimationProvider = ['$animateProvider', function($animateProvider) {
1919    return  element . data ( RUNNER_STORAGE_KEY ) ; 
2020  } 
2121
22-   this . $get  =  [ '$$jqLite' ,  '$rootScope' ,  '$injector' ,  '$$AnimateRunner' ,  '$$HashMap' , 
23-        function ( $$jqLite ,    $rootScope ,    $injector ,    $$AnimateRunner ,    $$HashMap )  { 
22+   this . $get  =  [ '$$jqLite' ,  '$rootScope' ,  '$injector' ,  '$$AnimateRunner' ,  '$$HashMap' ,   '$$rAFScheduler' , 
23+        function ( $$jqLite ,    $rootScope ,    $injector ,    $$AnimateRunner ,    $$HashMap ,     $$rAFScheduler )  { 
2424
2525    var  animationQueue  =  [ ] ; 
2626    var  applyAnimationClasses  =  applyAnimationClassesFactory ( $$jqLite ) ; 
@@ -88,26 +88,27 @@ var $$AnimationProvider = ['$animateProvider', function($animateProvider) {
8888          if  ( remainingLevelEntries  <=  0 )  { 
8989            remainingLevelEntries  =  nextLevelEntries ; 
9090            nextLevelEntries  =  0 ; 
91-             result   =   result . concat ( row ) ; 
91+             result . push ( row ) ; 
9292            row  =  [ ] ; 
9393          } 
9494          row . push ( entry . fn ) ; 
95-           forEach ( entry . children ,   function ( childEntry )  { 
95+           entry . children . forEach ( function ( childEntry )  { 
9696            nextLevelEntries ++ ; 
9797            queue . push ( childEntry ) ; 
9898          } ) ; 
9999          remainingLevelEntries -- ; 
100100        } 
101101
102102        if  ( row . length )  { 
103-           result   =   result . concat ( row ) ; 
103+           result . push ( row ) ; 
104104        } 
105+ 
105106        return  result ; 
106107      } 
107108    } 
108109
109110    // TODO(matsko): document the signature in a better way 
110-     return  function ( element ,  event ,  options ,   onBeforeClassesAppliedCb )  { 
111+     return  function ( element ,  event ,  options )  { 
111112      options  =  prepareAnimationOptions ( options ) ; 
112113      var  isStructural  =  [ 'enter' ,  'move' ,  'leave' ] . indexOf ( event )  >=  0 ; 
113114
@@ -159,8 +160,7 @@ var $$AnimationProvider = ['$animateProvider', function($animateProvider) {
159160          // the element was destroyed early on which removed the runner 
160161          // form its storage. This means we can't animate this element 
161162          // at all and it already has been closed due to destruction. 
162-           var  elm  =  entry . element ; 
163-           if  ( getRunner ( elm )  &&  getDomNode ( elm ) . parentNode )  { 
163+           if  ( getRunner ( entry . element ) )  { 
164164            animations . push ( entry ) ; 
165165          }  else  { 
166166            entry . close ( ) ; 
@@ -191,7 +191,7 @@ var $$AnimationProvider = ['$animateProvider', function($animateProvider) {
191191                  : animationEntry . element ; 
192192
193193              if  ( getRunner ( targetElement ) )  { 
194-                 var  operation  =  invokeFirstDriver ( animationEntry ,   onBeforeClassesAppliedCb ) ; 
194+                 var  operation  =  invokeFirstDriver ( animationEntry ) ; 
195195                if  ( operation )  { 
196196                  startAnimationFn  =  operation . start ; 
197197                } 
@@ -211,11 +211,9 @@ var $$AnimationProvider = ['$animateProvider', function($animateProvider) {
211211        } ) ; 
212212
213213        // we need to sort each of the animations in order of parent to child 
214-         // relationships. This ensures that the parent to child classes are 
215-         // applied at the right time. 
216-         forEach ( sortAnimations ( toBeSortedAnimations ) ,  function ( triggerAnimation )  { 
217-           triggerAnimation ( ) ; 
218-         } ) ; 
214+         // relationships. This ensures that the child classes are applied at the 
215+         // right time. 
216+         $$rAFScheduler ( sortAnimations ( toBeSortedAnimations ) ) ; 
219217      } ) ; 
220218
221219      return  runner ; 
@@ -285,7 +283,7 @@ var $$AnimationProvider = ['$animateProvider', function($animateProvider) {
285283          var  lookupKey  =  from . animationID . toString ( ) ; 
286284          if  ( ! anchorGroups [ lookupKey ] )  { 
287285            var  group  =  anchorGroups [ lookupKey ]  =  { 
288-               // TODO(matsko): double-check this code 
286+               structural :  true , 
289287              beforeStart : function ( )  { 
290288                fromAnimation . beforeStart ( ) ; 
291289                toAnimation . beforeStart ( ) ; 
@@ -339,15 +337,15 @@ var $$AnimationProvider = ['$animateProvider', function($animateProvider) {
339337        return  matches . join ( ' ' ) ; 
340338      } 
341339
342-       function  invokeFirstDriver ( animationDetails ,   onBeforeClassesAppliedCb )  { 
340+       function  invokeFirstDriver ( animationDetails )  { 
343341        // we loop in reverse order since the more general drivers (like CSS and JS) 
344342        // may attempt more elements, but custom drivers are more particular 
345343        for  ( var  i  =  drivers . length  -  1 ;  i  >=  0 ;  i -- )  { 
346344          var  driverName  =  drivers [ i ] ; 
347345          if  ( ! $injector . has ( driverName ) )  continue ;  // TODO(matsko): remove this check 
348346
349347          var  factory  =  $injector . get ( driverName ) ; 
350-           var  driver  =  factory ( animationDetails ,   onBeforeClassesAppliedCb ) ; 
348+           var  driver  =  factory ( animationDetails ) ; 
351349          if  ( driver )  { 
352350            return  driver ; 
353351          } 
0 commit comments