@@ -19,16 +19,12 @@ var $$AnimationProvider = ['$animateProvider', function($animateProvider) {
19
19
return element . data ( RUNNER_STORAGE_KEY ) ;
20
20
}
21
21
22
- this . $get = [ '$$jqLite' , '$rootScope' , '$injector' , '$$AnimateRunner' , '$$rAFScheduler' ,
23
- function ( $$jqLite , $rootScope , $injector , $$AnimateRunner , $$rAFScheduler ) {
22
+ this . $get = [ '$$jqLite' , '$rootScope' , '$injector' , '$$AnimateRunner' ,
23
+ function ( $$jqLite , $rootScope , $injector , $$AnimateRunner ) {
24
24
25
25
var animationQueue = [ ] ;
26
26
var applyAnimationClasses = applyAnimationClassesFactory ( $$jqLite ) ;
27
27
28
- var totalPendingClassBasedAnimations = 0 ;
29
- var totalActiveClassBasedAnimations = 0 ;
30
- var classBasedAnimationsQueue = [ ] ;
31
-
32
28
// TODO(matsko): document the signature in a better way
33
29
return function ( element , event , options ) {
34
30
options = prepareAnimationOptions ( options ) ;
@@ -57,19 +53,12 @@ var $$AnimationProvider = ['$animateProvider', function($animateProvider) {
57
53
options . tempClasses = null ;
58
54
}
59
55
60
- var classBasedIndex ;
61
- if ( ! isStructural ) {
62
- classBasedIndex = totalPendingClassBasedAnimations ;
63
- totalPendingClassBasedAnimations += 1 ;
64
- }
65
-
66
56
animationQueue . push ( {
67
57
// this data is used by the postDigest code and passed into
68
58
// the driver step function
69
59
element : element ,
70
60
classes : classes ,
71
61
event : event ,
72
- classBasedIndex : classBasedIndex ,
73
62
structural : isStructural ,
74
63
options : options ,
75
64
beforeStart : beforeStart ,
@@ -84,16 +73,13 @@ var $$AnimationProvider = ['$animateProvider', function($animateProvider) {
84
73
if ( animationQueue . length > 1 ) return runner ;
85
74
86
75
$rootScope . $$postDigest ( function ( ) {
87
- totalActiveClassBasedAnimations = totalPendingClassBasedAnimations ;
88
- totalPendingClassBasedAnimations = 0 ;
89
- classBasedAnimationsQueue . length = 0 ;
90
-
91
76
var animations = [ ] ;
92
77
forEach ( animationQueue , function ( entry ) {
93
78
// the element was destroyed early on which removed the runner
94
79
// form its storage. This means we can't animate this element
95
80
// at all and it already has been closed due to destruction.
96
- if ( getRunner ( entry . element ) ) {
81
+ var elm = entry . element ;
82
+ if ( getRunner ( elm ) && getDomNode ( elm ) . parentNode ) {
97
83
animations . push ( entry ) ;
98
84
}
99
85
} ) ;
@@ -102,58 +88,23 @@ var $$AnimationProvider = ['$animateProvider', function($animateProvider) {
102
88
animationQueue . length = 0 ;
103
89
104
90
forEach ( groupAnimations ( animations ) , function ( animationEntry ) {
105
- if ( animationEntry . structural ) {
106
- triggerAnimationStart ( ) ;
107
- } else {
108
- classBasedAnimationsQueue . push ( {
109
- node : getDomNode ( animationEntry . element ) ,
110
- fn : triggerAnimationStart
111
- } ) ;
112
-
113
- if ( animationEntry . classBasedIndex === totalActiveClassBasedAnimations - 1 ) {
114
- // we need to sort each of the animations in order of parent to child
115
- // relationships. This ensures that the child classes are applied at the
116
- // right time.
117
- classBasedAnimationsQueue = classBasedAnimationsQueue . sort ( function ( a , b ) {
118
- return b . node . contains ( a . node ) ;
119
- } ) . map ( function ( entry ) {
120
- return entry . fn ;
121
- } ) ;
122
-
123
- $$rAFScheduler ( classBasedAnimationsQueue ) ;
124
- }
125
- }
91
+ // it's important that we apply the `ng-animate` CSS class and the
92
+ // temporary classes before we do any driver invoking since these
93
+ // CSS classes may be required for proper CSS detection.
94
+ animationEntry . beforeStart ( ) ;
126
95
127
- function triggerAnimationStart ( ) {
128
- // it's important that we apply the `ng-animate` CSS class and the
129
- // temporary classes before we do any driver invoking since these
130
- // CSS classes may be required for proper CSS detection.
131
- animationEntry . beforeStart ( ) ;
132
-
133
- var startAnimationFn , closeFn = animationEntry . close ;
134
-
135
- // in the event that the element was removed before the digest runs or
136
- // during the RAF sequencing then we should not trigger the animation.
137
- var targetElement = animationEntry . anchors
138
- ? ( animationEntry . from . element || animationEntry . to . element )
139
- : animationEntry . element ;
140
-
141
- if ( getRunner ( targetElement ) && getDomNode ( targetElement ) . parentNode ) {
142
- var operation = invokeFirstDriver ( animationEntry ) ;
143
- if ( operation ) {
144
- startAnimationFn = operation . start ;
145
- }
146
- }
96
+ var operation = invokeFirstDriver ( animationEntry ) ;
97
+ var triggerAnimationStart = operation && operation . start ; /// TODO(matsko): only recognize operation.start()
147
98
148
- if ( ! startAnimationFn ) {
149
- closeFn ( ) ;
150
- } else {
151
- var animationRunner = startAnimationFn ( ) ;
152
- animationRunner . done ( function ( status ) {
153
- closeFn ( ! status ) ;
154
- } ) ;
155
- updateAnimationRunners ( animationEntry , animationRunner ) ;
156
- }
99
+ var closeFn = animationEntry . close ;
100
+ if ( ! triggerAnimationStart ) {
101
+ closeFn ( ) ;
102
+ } else {
103
+ var animationRunner = triggerAnimationStart ( ) ;
104
+ animationRunner . done ( function ( status ) {
105
+ closeFn ( ! status ) ;
106
+ } ) ;
107
+ updateAnimationRunners ( animationEntry , animationRunner ) ;
157
108
}
158
109
} ) ;
159
110
} ) ;
@@ -225,7 +176,7 @@ var $$AnimationProvider = ['$animateProvider', function($animateProvider) {
225
176
var lookupKey = from . animationID . toString ( ) ;
226
177
if ( ! anchorGroups [ lookupKey ] ) {
227
178
var group = anchorGroups [ lookupKey ] = {
228
- structural : true ,
179
+ // TODO(matsko): double-check this code
229
180
beforeStart : function ( ) {
230
181
fromAnimation . beforeStart ( ) ;
231
182
toAnimation . beforeStart ( ) ;
0 commit comments