@@ -147,8 +147,6 @@ var $AnimatorProvider = function() {
147
147
* @return {object } the animator object which contains the enter, leave, move, show, hide and animate methods.
148
148
*/
149
149
var AnimatorService = function ( scope , attrs ) {
150
- var ngAnimateAttr = attrs . ngAnimate ;
151
- var ngAnimateValue = ngAnimateAttr && scope . $eval ( ngAnimateAttr ) ;
152
150
var animator = { } ;
153
151
154
152
/**
@@ -223,24 +221,22 @@ var $AnimatorProvider = function() {
223
221
return animator ;
224
222
225
223
function animateActionFactory ( type , beforeFn , afterFn ) {
226
- var className = ngAnimateAttr
227
- ? isObject ( ngAnimateValue ) ? ngAnimateValue [ type ] : ngAnimateValue + '-' + type
228
- : '' ;
229
- var animationPolyfill = $animation ( className ) ;
230
-
231
- var polyfillSetup = animationPolyfill && animationPolyfill . setup ;
232
- var polyfillStart = animationPolyfill && animationPolyfill . start ;
233
-
234
- if ( ! className ) {
235
- return function ( element , parent , after ) {
224
+ return function ( element , parent , after ) {
225
+ var ngAnimateValue = scope . $eval ( attrs . ngAnimate ) ;
226
+ var className = ngAnimateValue
227
+ ? isObject ( ngAnimateValue ) ? ngAnimateValue [ type ] : ngAnimateValue + '-' + type
228
+ : '' ;
229
+ var animationPolyfill = $animation ( className ) ;
230
+ var polyfillSetup = animationPolyfill && animationPolyfill . setup ;
231
+ var polyfillStart = animationPolyfill && animationPolyfill . start ;
232
+
233
+ if ( ! className ) {
236
234
beforeFn ( element , parent , after ) ;
237
235
afterFn ( element , parent , after ) ;
238
- }
239
- } else {
240
- var setupClass = className + '-setup' ;
241
- var startClass = className + '-start' ;
242
-
243
- return function ( element , parent , after ) {
236
+ } else {
237
+ var setupClass = className + '-setup' ;
238
+ var startClass = className + '-start' ;
239
+
244
240
if ( ! parent ) {
245
241
parent = after ? after . parent ( ) : element . parent ( ) ;
246
242
}
@@ -255,48 +251,48 @@ var $AnimatorProvider = function() {
255
251
element . addClass ( setupClass ) ;
256
252
beforeFn ( element , parent , after ) ;
257
253
if ( element . length == 0 ) return done ( ) ;
258
-
254
+
259
255
var memento = ( polyfillSetup || noop ) ( element ) ;
260
-
256
+
261
257
// $window.setTimeout(beginAnimation, 0); this was causing the element not to animate
262
258
// keep at 1 for animation dom rerender
263
259
$window . setTimeout ( beginAnimation , 1 ) ;
264
-
265
- function beginAnimation ( ) {
266
- element . addClass ( startClass ) ;
267
- if ( polyfillStart ) {
268
- polyfillStart ( element , done , memento ) ;
269
- } else if ( isFunction ( $window . getComputedStyle ) ) {
270
- var vendorTransitionProp = $sniffer . vendorPrefix + 'Transition' ;
271
- var w3cTransitionProp = 'transition' ; //one day all browsers will have this
272
-
273
- var durationKey = 'Duration' ;
274
- var duration = 0 ;
260
+ } ;
275
261
276
- //we want all the styles defined before and after
277
- forEach ( element , function ( element ) {
278
- if ( element . nodeType == 1 ) {
279
- var globalStyles = $window . getComputedStyle ( element ) || { } ;
280
- duration = Math . max (
281
- parseFloat ( globalStyles [ w3cTransitionProp + durationKey ] ) ||
282
- parseFloat ( globalStyles [ vendorTransitionProp + durationKey ] ) ||
283
- 0 ,
284
- duration ) ;
285
- }
286
- } ) ;
287
- $window . setTimeout ( done , duration * 1000 ) ;
288
- } else {
289
- done ( ) ;
290
- }
291
- }
292
-
293
- function done ( ) {
294
- afterFn ( element , parent , after ) ;
295
- element . removeClass ( setupClass ) ;
296
- element . removeClass ( startClass ) ;
297
- element . removeData ( NG_ANIMATE_CONTROLLER ) ;
262
+ function beginAnimation ( ) {
263
+ element . addClass ( startClass ) ;
264
+ if ( polyfillStart ) {
265
+ polyfillStart ( element , done , memento ) ;
266
+ } else if ( isFunction ( $window . getComputedStyle ) ) {
267
+ var vendorTransitionProp = $sniffer . vendorPrefix + 'Transition' ;
268
+ var w3cTransitionProp = 'transition' ; //one day all browsers will have this
269
+
270
+ var durationKey = 'Duration' ;
271
+ var duration = 0 ;
272
+
273
+ //we want all the styles defined before and after
274
+ forEach ( element , function ( element ) {
275
+ if ( element . nodeType == 1 ) {
276
+ var globalStyles = $window . getComputedStyle ( element ) || { } ;
277
+ duration = Math . max (
278
+ parseFloat ( globalStyles [ w3cTransitionProp + durationKey ] ) ||
279
+ parseFloat ( globalStyles [ vendorTransitionProp + durationKey ] ) ||
280
+ 0 ,
281
+ duration ) ;
282
+ }
283
+ } ) ;
284
+ $window . setTimeout ( done , duration * 1000 ) ;
285
+ } else {
286
+ done ( ) ;
298
287
}
299
288
}
289
+
290
+ function done ( ) {
291
+ afterFn ( element , parent , after ) ;
292
+ element . removeClass ( setupClass ) ;
293
+ element . removeClass ( startClass ) ;
294
+ element . removeData ( NG_ANIMATE_CONTROLLER ) ;
295
+ }
300
296
}
301
297
}
302
298
0 commit comments