angular-gem 1.2.14 → 1.2.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWQ0ODc4MjljYTMyODIyMTU1YTJlZTBmNjA5MmQwMmQ4NjEzYzNlNA==
4
+ ZTAxZTI2YTBiNWEzNTE5ZDEwZjZjZjdkNjAzOTQ5YWM4MTdiNTljZg==
5
5
  data.tar.gz: !binary |-
6
- ZmY3NjA0Y2QxMTMyNGE1MTAyYjUwZDkxZDQ5ZjdiNTMwYmJlMzQ3Zg==
6
+ MTkwY2Q1NTUwYjAzZWVmYmE2ZDE5MjhiODkxYWNiZmJlMWE2MzQ4Nw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjgyNGZlZDgzZDlhNGU1YmMwMmZlMzE3NGNkNmYwNWVlNmE1Y2RhNmQyMzli
10
- MDExY2JmYTYyNDA3NDQxZmVkMmZlYTI5OTAxYTg0ZGRhNWYyODRhZWExYTg2
11
- MzJhZjljZjJhMzk3ZTRjN2M2M2Q3NzVhMGQ0NGJhZTk4MjhkMWI=
9
+ NmE4ZDg2ZGE3NzY4NTU2YzJjMjFjODEyZjZlOGNjMWU4OGIwZjhlNjc2N2Vh
10
+ YzY0YWFmNmYxZTE0N2ViZDllOGZiZTZjMGU1N2IxMGEwZDkwOTk2OGIzZTJl
11
+ MzhiNTg1OWU5NGViYjYwMDVkZTdjODJlODc4OGRlMTU3YWY3Zjc=
12
12
  data.tar.gz: !binary |-
13
- Y2NkODMzMjI4MTY0YTU0MDJmMTZhNjUzMDQxMjJmMmE4MzYzOTM0ODA4YzM3
14
- NjBhMzI4YjA5YWI1NDY1YmU1OWJhZjViNDdhODlhYjQyZGZiNjQzMTI2MThk
15
- MDQ1NGEzYjEzZDQxOWI3NGU2ZjAzNzhhYzAyZjljNTE5MmFiMjk=
13
+ YmUwYmMxMDk3ZjE4NDYxY2RjMDQ4MDlmZGFiYThkNWU1ZDA1NjIxNGZhMzA2
14
+ MzQzMTMxN2I5YTg3NjYwYmY1MWY3MWNmNDJjZGUwMWEyOTg1ODc5ZmFkYzEy
15
+ ZjkzODBiY2QzNzI1ZjM0NDU4NjY0YzYxNmUzZGY5ZmUzMDBmMDE=
@@ -1,3 +1,3 @@
1
1
  module AngularGem
2
- VERSION = "1.2.14"
2
+ VERSION = "1.2.15"
3
3
  end
@@ -0,0 +1,1613 @@
1
+ /**
2
+ * @license AngularJS v1.2.15
3
+ * (c) 2010-2014 Google, Inc. http://angularjs.org
4
+ * License: MIT
5
+ */
6
+ (function(window, angular, undefined) {'use strict';
7
+
8
+ /* jshint maxlen: false */
9
+
10
+ /**
11
+ * @ngdoc module
12
+ * @name ngAnimate
13
+ * @description
14
+ *
15
+ * # ngAnimate
16
+ *
17
+ * The `ngAnimate` module provides support for JavaScript, CSS3 transition and CSS3 keyframe animation hooks within existing core and custom directives.
18
+ *
19
+ *
20
+ * <div doc-module-components="ngAnimate"></div>
21
+ *
22
+ * # Usage
23
+ *
24
+ * To see animations in action, all that is required is to define the appropriate CSS classes
25
+ * or to register a JavaScript animation via the myModule.animation() function. The directives that support animation automatically are:
26
+ * `ngRepeat`, `ngInclude`, `ngIf`, `ngSwitch`, `ngShow`, `ngHide`, `ngView` and `ngClass`. Custom directives can take advantage of animation
27
+ * by using the `$animate` service.
28
+ *
29
+ * Below is a more detailed breakdown of the supported animation events provided by pre-existing ng directives:
30
+ *
31
+ * | Directive | Supported Animations |
32
+ * |---------------------------------------------------------- |----------------------------------------------------|
33
+ * | {@link ng.directive:ngRepeat#usage_animations ngRepeat} | enter, leave and move |
34
+ * | {@link ngRoute.directive:ngView#usage_animations ngView} | enter and leave |
35
+ * | {@link ng.directive:ngInclude#usage_animations ngInclude} | enter and leave |
36
+ * | {@link ng.directive:ngSwitch#usage_animations ngSwitch} | enter and leave |
37
+ * | {@link ng.directive:ngIf#usage_animations ngIf} | enter and leave |
38
+ * | {@link ng.directive:ngClass#usage_animations ngClass} | add and remove |
39
+ * | {@link ng.directive:ngShow#usage_animations ngShow & ngHide} | add and remove (the ng-hide class value) |
40
+ * | {@link ng.directive:form#usage_animations form} | add and remove (dirty, pristine, valid, invalid & all other validations) |
41
+ * | {@link ng.directive:ngModel#usage_animations ngModel} | add and remove (dirty, pristine, valid, invalid & all other validations) |
42
+ *
43
+ * You can find out more information about animations upon visiting each directive page.
44
+ *
45
+ * Below is an example of how to apply animations to a directive that supports animation hooks:
46
+ *
47
+ * ```html
48
+ * <style type="text/css">
49
+ * .slide.ng-enter, .slide.ng-leave {
50
+ * -webkit-transition:0.5s linear all;
51
+ * transition:0.5s linear all;
52
+ * }
53
+ *
54
+ * .slide.ng-enter { } /&#42; starting animations for enter &#42;/
55
+ * .slide.ng-enter-active { } /&#42; terminal animations for enter &#42;/
56
+ * .slide.ng-leave { } /&#42; starting animations for leave &#42;/
57
+ * .slide.ng-leave-active { } /&#42; terminal animations for leave &#42;/
58
+ * </style>
59
+ *
60
+ * <!--
61
+ * the animate service will automatically add .ng-enter and .ng-leave to the element
62
+ * to trigger the CSS transition/animations
63
+ * -->
64
+ * <ANY class="slide" ng-include="..."></ANY>
65
+ * ```
66
+ *
67
+ * Keep in mind that if an animation is running, any child elements cannot be animated until the parent element's
68
+ * animation has completed.
69
+ *
70
+ * <h2>CSS-defined Animations</h2>
71
+ * The animate service will automatically apply two CSS classes to the animated element and these two CSS classes
72
+ * are designed to contain the start and end CSS styling. Both CSS transitions and keyframe animations are supported
73
+ * and can be used to play along with this naming structure.
74
+ *
75
+ * The following code below demonstrates how to perform animations using **CSS transitions** with Angular:
76
+ *
77
+ * ```html
78
+ * <style type="text/css">
79
+ * /&#42;
80
+ * The animate class is apart of the element and the ng-enter class
81
+ * is attached to the element once the enter animation event is triggered
82
+ * &#42;/
83
+ * .reveal-animation.ng-enter {
84
+ * -webkit-transition: 1s linear all; /&#42; Safari/Chrome &#42;/
85
+ * transition: 1s linear all; /&#42; All other modern browsers and IE10+ &#42;/
86
+ *
87
+ * /&#42; The animation preparation code &#42;/
88
+ * opacity: 0;
89
+ * }
90
+ *
91
+ * /&#42;
92
+ * Keep in mind that you want to combine both CSS
93
+ * classes together to avoid any CSS-specificity
94
+ * conflicts
95
+ * &#42;/
96
+ * .reveal-animation.ng-enter.ng-enter-active {
97
+ * /&#42; The animation code itself &#42;/
98
+ * opacity: 1;
99
+ * }
100
+ * </style>
101
+ *
102
+ * <div class="view-container">
103
+ * <div ng-view class="reveal-animation"></div>
104
+ * </div>
105
+ * ```
106
+ *
107
+ * The following code below demonstrates how to perform animations using **CSS animations** with Angular:
108
+ *
109
+ * ```html
110
+ * <style type="text/css">
111
+ * .reveal-animation.ng-enter {
112
+ * -webkit-animation: enter_sequence 1s linear; /&#42; Safari/Chrome &#42;/
113
+ * animation: enter_sequence 1s linear; /&#42; IE10+ and Future Browsers &#42;/
114
+ * }
115
+ * &#64-webkit-keyframes enter_sequence {
116
+ * from { opacity:0; }
117
+ * to { opacity:1; }
118
+ * }
119
+ * &#64keyframes enter_sequence {
120
+ * from { opacity:0; }
121
+ * to { opacity:1; }
122
+ * }
123
+ * </style>
124
+ *
125
+ * <div class="view-container">
126
+ * <div ng-view class="reveal-animation"></div>
127
+ * </div>
128
+ * ```
129
+ *
130
+ * Both CSS3 animations and transitions can be used together and the animate service will figure out the correct duration and delay timing.
131
+ *
132
+ * Upon DOM mutation, the event class is added first (something like `ng-enter`), then the browser prepares itself to add
133
+ * the active class (in this case `ng-enter-active`) which then triggers the animation. The animation module will automatically
134
+ * detect the CSS code to determine when the animation ends. Once the animation is over then both CSS classes will be
135
+ * removed from the DOM. If a browser does not support CSS transitions or CSS animations then the animation will start and end
136
+ * immediately resulting in a DOM element that is at its final state. This final state is when the DOM element
137
+ * has no CSS transition/animation classes applied to it.
138
+ *
139
+ * <h3>CSS Staggering Animations</h3>
140
+ * A Staggering animation is a collection of animations that are issued with a slight delay in between each successive operation resulting in a
141
+ * curtain-like effect. The ngAnimate module, as of 1.2.0, supports staggering animations and the stagger effect can be
142
+ * performed by creating a **ng-EVENT-stagger** CSS class and attaching that class to the base CSS class used for
143
+ * the animation. The style property expected within the stagger class can either be a **transition-delay** or an
144
+ * **animation-delay** property (or both if your animation contains both transitions and keyframe animations).
145
+ *
146
+ * ```css
147
+ * .my-animation.ng-enter {
148
+ * /&#42; standard transition code &#42;/
149
+ * -webkit-transition: 1s linear all;
150
+ * transition: 1s linear all;
151
+ * opacity:0;
152
+ * }
153
+ * .my-animation.ng-enter-stagger {
154
+ * /&#42; this will have a 100ms delay between each successive leave animation &#42;/
155
+ * -webkit-transition-delay: 0.1s;
156
+ * transition-delay: 0.1s;
157
+ *
158
+ * /&#42; in case the stagger doesn't work then these two values
159
+ * must be set to 0 to avoid an accidental CSS inheritance &#42;/
160
+ * -webkit-transition-duration: 0s;
161
+ * transition-duration: 0s;
162
+ * }
163
+ * .my-animation.ng-enter.ng-enter-active {
164
+ * /&#42; standard transition styles &#42;/
165
+ * opacity:1;
166
+ * }
167
+ * ```
168
+ *
169
+ * Staggering animations work by default in ngRepeat (so long as the CSS class is defined). Outside of ngRepeat, to use staggering animations
170
+ * on your own, they can be triggered by firing multiple calls to the same event on $animate. However, the restrictions surrounding this
171
+ * are that each of the elements must have the same CSS className value as well as the same parent element. A stagger operation
172
+ * will also be reset if more than 10ms has passed after the last animation has been fired.
173
+ *
174
+ * The following code will issue the **ng-leave-stagger** event on the element provided:
175
+ *
176
+ * ```js
177
+ * var kids = parent.children();
178
+ *
179
+ * $animate.leave(kids[0]); //stagger index=0
180
+ * $animate.leave(kids[1]); //stagger index=1
181
+ * $animate.leave(kids[2]); //stagger index=2
182
+ * $animate.leave(kids[3]); //stagger index=3
183
+ * $animate.leave(kids[4]); //stagger index=4
184
+ *
185
+ * $timeout(function() {
186
+ * //stagger has reset itself
187
+ * $animate.leave(kids[5]); //stagger index=0
188
+ * $animate.leave(kids[6]); //stagger index=1
189
+ * }, 100, false);
190
+ * ```
191
+ *
192
+ * Stagger animations are currently only supported within CSS-defined animations.
193
+ *
194
+ * <h2>JavaScript-defined Animations</h2>
195
+ * In the event that you do not want to use CSS3 transitions or CSS3 animations or if you wish to offer animations on browsers that do not
196
+ * yet support CSS transitions/animations, then you can make use of JavaScript animations defined inside of your AngularJS module.
197
+ *
198
+ * ```js
199
+ * //!annotate="YourApp" Your AngularJS Module|Replace this or ngModule with the module that you used to define your application.
200
+ * var ngModule = angular.module('YourApp', ['ngAnimate']);
201
+ * ngModule.animation('.my-crazy-animation', function() {
202
+ * return {
203
+ * enter: function(element, done) {
204
+ * //run the animation here and call done when the animation is complete
205
+ * return function(cancelled) {
206
+ * //this (optional) function will be called when the animation
207
+ * //completes or when the animation is cancelled (the cancelled
208
+ * //flag will be set to true if cancelled).
209
+ * };
210
+ * },
211
+ * leave: function(element, done) { },
212
+ * move: function(element, done) { },
213
+ *
214
+ * //animation that can be triggered before the class is added
215
+ * beforeAddClass: function(element, className, done) { },
216
+ *
217
+ * //animation that can be triggered after the class is added
218
+ * addClass: function(element, className, done) { },
219
+ *
220
+ * //animation that can be triggered before the class is removed
221
+ * beforeRemoveClass: function(element, className, done) { },
222
+ *
223
+ * //animation that can be triggered after the class is removed
224
+ * removeClass: function(element, className, done) { }
225
+ * };
226
+ * });
227
+ * ```
228
+ *
229
+ * JavaScript-defined animations are created with a CSS-like class selector and a collection of events which are set to run
230
+ * a javascript callback function. When an animation is triggered, $animate will look for a matching animation which fits
231
+ * the element's CSS class attribute value and then run the matching animation event function (if found).
232
+ * In other words, if the CSS classes present on the animated element match any of the JavaScript animations then the callback function will
233
+ * be executed. It should be also noted that only simple, single class selectors are allowed (compound class selectors are not supported).
234
+ *
235
+ * Within a JavaScript animation, an object containing various event callback animation functions is expected to be returned.
236
+ * As explained above, these callbacks are triggered based on the animation event. Therefore if an enter animation is run,
237
+ * and the JavaScript animation is found, then the enter callback will handle that animation (in addition to the CSS keyframe animation
238
+ * or transition code that is defined via a stylesheet).
239
+ *
240
+ */
241
+
242
+ angular.module('ngAnimate', ['ng'])
243
+
244
+ /**
245
+ * @ngdoc provider
246
+ * @name $animateProvider
247
+ * @description
248
+ *
249
+ * The `$animateProvider` allows developers to register JavaScript animation event handlers directly inside of a module.
250
+ * When an animation is triggered, the $animate service will query the $animate service to find any animations that match
251
+ * the provided name value.
252
+ *
253
+ * Requires the {@link ngAnimate `ngAnimate`} module to be installed.
254
+ *
255
+ * Please visit the {@link ngAnimate `ngAnimate`} module overview page learn more about how to use animations in your application.
256
+ *
257
+ */
258
+
259
+ //this private service is only used within CSS-enabled animations
260
+ //IE8 + IE9 do not support rAF natively, but that is fine since they
261
+ //also don't support transitions and keyframes which means that the code
262
+ //below will never be used by the two browsers.
263
+ .factory('$$animateReflow', ['$$rAF', '$document', function($$rAF, $document) {
264
+ var bod = $document[0].body;
265
+ return function(fn) {
266
+ //the returned function acts as the cancellation function
267
+ return $$rAF(function() {
268
+ //the line below will force the browser to perform a repaint
269
+ //so that all the animated elements within the animation frame
270
+ //will be properly updated and drawn on screen. This is
271
+ //required to perform multi-class CSS based animations with
272
+ //Firefox. DO NOT REMOVE THIS LINE.
273
+ var a = bod.offsetWidth + 1;
274
+ fn();
275
+ });
276
+ };
277
+ }])
278
+
279
+ .config(['$provide', '$animateProvider', function($provide, $animateProvider) {
280
+ var noop = angular.noop;
281
+ var forEach = angular.forEach;
282
+ var selectors = $animateProvider.$$selectors;
283
+
284
+ var ELEMENT_NODE = 1;
285
+ var NG_ANIMATE_STATE = '$$ngAnimateState';
286
+ var NG_ANIMATE_CLASS_NAME = 'ng-animate';
287
+ var rootAnimateState = {running: true};
288
+
289
+ function extractElementNode(element) {
290
+ for(var i = 0; i < element.length; i++) {
291
+ var elm = element[i];
292
+ if(elm.nodeType == ELEMENT_NODE) {
293
+ return elm;
294
+ }
295
+ }
296
+ }
297
+
298
+ function stripCommentsFromElement(element) {
299
+ return angular.element(extractElementNode(element));
300
+ }
301
+
302
+ function isMatchingElement(elm1, elm2) {
303
+ return extractElementNode(elm1) == extractElementNode(elm2);
304
+ }
305
+
306
+ $provide.decorator('$animate', ['$delegate', '$injector', '$sniffer', '$rootElement', '$$asyncCallback', '$rootScope', '$document',
307
+ function($delegate, $injector, $sniffer, $rootElement, $$asyncCallback, $rootScope, $document) {
308
+
309
+ var globalAnimationCounter = 0;
310
+ $rootElement.data(NG_ANIMATE_STATE, rootAnimateState);
311
+
312
+ // disable animations during bootstrap, but once we bootstrapped, wait again
313
+ // for another digest until enabling animations. The reason why we digest twice
314
+ // is because all structural animations (enter, leave and move) all perform a
315
+ // post digest operation before animating. If we only wait for a single digest
316
+ // to pass then the structural animation would render its animation on page load.
317
+ // (which is what we're trying to avoid when the application first boots up.)
318
+ $rootScope.$$postDigest(function() {
319
+ $rootScope.$$postDigest(function() {
320
+ rootAnimateState.running = false;
321
+ });
322
+ });
323
+
324
+ var classNameFilter = $animateProvider.classNameFilter();
325
+ var isAnimatableClassName = !classNameFilter
326
+ ? function() { return true; }
327
+ : function(className) {
328
+ return classNameFilter.test(className);
329
+ };
330
+
331
+ function lookup(name) {
332
+ if (name) {
333
+ var matches = [],
334
+ flagMap = {},
335
+ classes = name.substr(1).split('.');
336
+
337
+ //the empty string value is the default animation
338
+ //operation which performs CSS transition and keyframe
339
+ //animations sniffing. This is always included for each
340
+ //element animation procedure if the browser supports
341
+ //transitions and/or keyframe animations
342
+ if ($sniffer.transitions || $sniffer.animations) {
343
+ classes.push('');
344
+ }
345
+
346
+ for(var i=0; i < classes.length; i++) {
347
+ var klass = classes[i],
348
+ selectorFactoryName = selectors[klass];
349
+ if(selectorFactoryName && !flagMap[klass]) {
350
+ matches.push($injector.get(selectorFactoryName));
351
+ flagMap[klass] = true;
352
+ }
353
+ }
354
+ return matches;
355
+ }
356
+ }
357
+
358
+ function animationRunner(element, animationEvent, className) {
359
+ //transcluded directives may sometimes fire an animation using only comment nodes
360
+ //best to catch this early on to prevent any animation operations from occurring
361
+ var node = element[0];
362
+ if(!node) {
363
+ return;
364
+ }
365
+
366
+ var isSetClassOperation = animationEvent == 'setClass';
367
+ var isClassBased = isSetClassOperation ||
368
+ animationEvent == 'addClass' ||
369
+ animationEvent == 'removeClass';
370
+
371
+ var classNameAdd, classNameRemove;
372
+ if(angular.isArray(className)) {
373
+ classNameAdd = className[0];
374
+ classNameRemove = className[1];
375
+ className = classNameAdd + ' ' + classNameRemove;
376
+ }
377
+
378
+ var currentClassName = element.attr('class');
379
+ var classes = currentClassName + ' ' + className;
380
+ if(!isAnimatableClassName(classes)) {
381
+ return;
382
+ }
383
+
384
+ var beforeComplete = noop,
385
+ beforeCancel = [],
386
+ before = [],
387
+ afterComplete = noop,
388
+ afterCancel = [],
389
+ after = [];
390
+
391
+ var animationLookup = (' ' + classes).replace(/\s+/g,'.');
392
+ forEach(lookup(animationLookup), function(animationFactory) {
393
+ var created = registerAnimation(animationFactory, animationEvent);
394
+ if(!created && isSetClassOperation) {
395
+ registerAnimation(animationFactory, 'addClass');
396
+ registerAnimation(animationFactory, 'removeClass');
397
+ }
398
+ });
399
+
400
+ function registerAnimation(animationFactory, event) {
401
+ var afterFn = animationFactory[event];
402
+ var beforeFn = animationFactory['before' + event.charAt(0).toUpperCase() + event.substr(1)];
403
+ if(afterFn || beforeFn) {
404
+ if(event == 'leave') {
405
+ beforeFn = afterFn;
406
+ //when set as null then animation knows to skip this phase
407
+ afterFn = null;
408
+ }
409
+ after.push({
410
+ event : event, fn : afterFn
411
+ });
412
+ before.push({
413
+ event : event, fn : beforeFn
414
+ });
415
+ return true;
416
+ }
417
+ }
418
+
419
+ function run(fns, cancellations, allCompleteFn) {
420
+ var animations = [];
421
+ forEach(fns, function(animation) {
422
+ animation.fn && animations.push(animation);
423
+ });
424
+
425
+ var count = 0;
426
+ function afterAnimationComplete(index) {
427
+ if(cancellations) {
428
+ (cancellations[index] || noop)();
429
+ if(++count < animations.length) return;
430
+ cancellations = null;
431
+ }
432
+ allCompleteFn();
433
+ }
434
+
435
+ //The code below adds directly to the array in order to work with
436
+ //both sync and async animations. Sync animations are when the done()
437
+ //operation is called right away. DO NOT REFACTOR!
438
+ forEach(animations, function(animation, index) {
439
+ var progress = function() {
440
+ afterAnimationComplete(index);
441
+ };
442
+ switch(animation.event) {
443
+ case 'setClass':
444
+ cancellations.push(animation.fn(element, classNameAdd, classNameRemove, progress));
445
+ break;
446
+ case 'addClass':
447
+ cancellations.push(animation.fn(element, classNameAdd || className, progress));
448
+ break;
449
+ case 'removeClass':
450
+ cancellations.push(animation.fn(element, classNameRemove || className, progress));
451
+ break;
452
+ default:
453
+ cancellations.push(animation.fn(element, progress));
454
+ break;
455
+ }
456
+ });
457
+
458
+ if(cancellations && cancellations.length === 0) {
459
+ allCompleteFn();
460
+ }
461
+ }
462
+
463
+ return {
464
+ node : node,
465
+ event : animationEvent,
466
+ className : className,
467
+ isClassBased : isClassBased,
468
+ isSetClassOperation : isSetClassOperation,
469
+ before : function(allCompleteFn) {
470
+ beforeComplete = allCompleteFn;
471
+ run(before, beforeCancel, function() {
472
+ beforeComplete = noop;
473
+ allCompleteFn();
474
+ });
475
+ },
476
+ after : function(allCompleteFn) {
477
+ afterComplete = allCompleteFn;
478
+ run(after, afterCancel, function() {
479
+ afterComplete = noop;
480
+ allCompleteFn();
481
+ });
482
+ },
483
+ cancel : function() {
484
+ if(beforeCancel) {
485
+ forEach(beforeCancel, function(cancelFn) {
486
+ (cancelFn || noop)(true);
487
+ });
488
+ beforeComplete(true);
489
+ }
490
+ if(afterCancel) {
491
+ forEach(afterCancel, function(cancelFn) {
492
+ (cancelFn || noop)(true);
493
+ });
494
+ afterComplete(true);
495
+ }
496
+ }
497
+ };
498
+ }
499
+
500
+ /**
501
+ * @ngdoc service
502
+ * @name $animate
503
+ * @function
504
+ *
505
+ * @description
506
+ * The `$animate` service provides animation detection support while performing DOM operations (enter, leave and move) as well as during addClass and removeClass operations.
507
+ * When any of these operations are run, the $animate service
508
+ * will examine any JavaScript-defined animations (which are defined by using the $animateProvider provider object)
509
+ * as well as any CSS-defined animations against the CSS classes present on the element once the DOM operation is run.
510
+ *
511
+ * The `$animate` service is used behind the scenes with pre-existing directives and animation with these directives
512
+ * will work out of the box without any extra configuration.
513
+ *
514
+ * Requires the {@link ngAnimate `ngAnimate`} module to be installed.
515
+ *
516
+ * Please visit the {@link ngAnimate `ngAnimate`} module overview page learn more about how to use animations in your application.
517
+ *
518
+ */
519
+ return {
520
+ /**
521
+ * @ngdoc method
522
+ * @name $animate#enter
523
+ * @function
524
+ *
525
+ * @description
526
+ * Appends the element to the parentElement element that resides in the document and then runs the enter animation. Once
527
+ * the animation is started, the following CSS classes will be present on the element for the duration of the animation:
528
+ *
529
+ * Below is a breakdown of each step that occurs during enter animation:
530
+ *
531
+ * | Animation Step | What the element class attribute looks like |
532
+ * |----------------------------------------------------------------------------------------------|---------------------------------------------|
533
+ * | 1. $animate.enter(...) is called | class="my-animation" |
534
+ * | 2. element is inserted into the parentElement element or beside the afterElement element | class="my-animation" |
535
+ * | 3. $animate runs any JavaScript-defined animations on the element | class="my-animation ng-animate" |
536
+ * | 4. the .ng-enter class is added to the element | class="my-animation ng-animate ng-enter" |
537
+ * | 5. $animate scans the element styles to get the CSS transition/animation duration and delay | class="my-animation ng-animate ng-enter" |
538
+ * | 6. $animate waits for 10ms (this performs a reflow) | class="my-animation ng-animate ng-enter" |
539
+ * | 7. the .ng-enter-active and .ng-animate-active classes are added (this triggers the CSS transition/animation) | class="my-animation ng-animate ng-animate-active ng-enter ng-enter-active" |
540
+ * | 8. $animate waits for X milliseconds for the animation to complete | class="my-animation ng-animate ng-animate-active ng-enter ng-enter-active" |
541
+ * | 9. The animation ends and all generated CSS classes are removed from the element | class="my-animation" |
542
+ * | 10. The doneCallback() callback is fired (if provided) | class="my-animation" |
543
+ *
544
+ * @param {DOMElement} element the element that will be the focus of the enter animation
545
+ * @param {DOMElement} parentElement the parent element of the element that will be the focus of the enter animation
546
+ * @param {DOMElement} afterElement the sibling element (which is the previous element) of the element that will be the focus of the enter animation
547
+ * @param {function()=} doneCallback the callback function that will be called once the animation is complete
548
+ */
549
+ enter : function(element, parentElement, afterElement, doneCallback) {
550
+ this.enabled(false, element);
551
+ $delegate.enter(element, parentElement, afterElement);
552
+ $rootScope.$$postDigest(function() {
553
+ element = stripCommentsFromElement(element);
554
+ performAnimation('enter', 'ng-enter', element, parentElement, afterElement, noop, doneCallback);
555
+ });
556
+ },
557
+
558
+ /**
559
+ * @ngdoc method
560
+ * @name $animate#leave
561
+ * @function
562
+ *
563
+ * @description
564
+ * Runs the leave animation operation and, upon completion, removes the element from the DOM. Once
565
+ * the animation is started, the following CSS classes will be added for the duration of the animation:
566
+ *
567
+ * Below is a breakdown of each step that occurs during leave animation:
568
+ *
569
+ * | Animation Step | What the element class attribute looks like |
570
+ * |----------------------------------------------------------------------------------------------|---------------------------------------------|
571
+ * | 1. $animate.leave(...) is called | class="my-animation" |
572
+ * | 2. $animate runs any JavaScript-defined animations on the element | class="my-animation ng-animate" |
573
+ * | 3. the .ng-leave class is added to the element | class="my-animation ng-animate ng-leave" |
574
+ * | 4. $animate scans the element styles to get the CSS transition/animation duration and delay | class="my-animation ng-animate ng-leave" |
575
+ * | 5. $animate waits for 10ms (this performs a reflow) | class="my-animation ng-animate ng-leave" |
576
+ * | 6. the .ng-leave-active and .ng-animate-active classes is added (this triggers the CSS transition/animation) | class="my-animation ng-animate ng-animate-active ng-leave ng-leave-active" |
577
+ * | 7. $animate waits for X milliseconds for the animation to complete | class="my-animation ng-animate ng-animate-active ng-leave ng-leave-active" |
578
+ * | 8. The animation ends and all generated CSS classes are removed from the element | class="my-animation" |
579
+ * | 9. The element is removed from the DOM | ... |
580
+ * | 10. The doneCallback() callback is fired (if provided) | ... |
581
+ *
582
+ * @param {DOMElement} element the element that will be the focus of the leave animation
583
+ * @param {function()=} doneCallback the callback function that will be called once the animation is complete
584
+ */
585
+ leave : function(element, doneCallback) {
586
+ cancelChildAnimations(element);
587
+ this.enabled(false, element);
588
+ $rootScope.$$postDigest(function() {
589
+ performAnimation('leave', 'ng-leave', stripCommentsFromElement(element), null, null, function() {
590
+ $delegate.leave(element);
591
+ }, doneCallback);
592
+ });
593
+ },
594
+
595
+ /**
596
+ * @ngdoc method
597
+ * @name $animate#move
598
+ * @function
599
+ *
600
+ * @description
601
+ * Fires the move DOM operation. Just before the animation starts, the animate service will either append it into the parentElement container or
602
+ * add the element directly after the afterElement element if present. Then the move animation will be run. Once
603
+ * the animation is started, the following CSS classes will be added for the duration of the animation:
604
+ *
605
+ * Below is a breakdown of each step that occurs during move animation:
606
+ *
607
+ * | Animation Step | What the element class attribute looks like |
608
+ * |----------------------------------------------------------------------------------------------|---------------------------------------------|
609
+ * | 1. $animate.move(...) is called | class="my-animation" |
610
+ * | 2. element is moved into the parentElement element or beside the afterElement element | class="my-animation" |
611
+ * | 3. $animate runs any JavaScript-defined animations on the element | class="my-animation ng-animate" |
612
+ * | 4. the .ng-move class is added to the element | class="my-animation ng-animate ng-move" |
613
+ * | 5. $animate scans the element styles to get the CSS transition/animation duration and delay | class="my-animation ng-animate ng-move" |
614
+ * | 6. $animate waits for 10ms (this performs a reflow) | class="my-animation ng-animate ng-move" |
615
+ * | 7. the .ng-move-active and .ng-animate-active classes is added (this triggers the CSS transition/animation) | class="my-animation ng-animate ng-animate-active ng-move ng-move-active" |
616
+ * | 8. $animate waits for X milliseconds for the animation to complete | class="my-animation ng-animate ng-animate-active ng-move ng-move-active" |
617
+ * | 9. The animation ends and all generated CSS classes are removed from the element | class="my-animation" |
618
+ * | 10. The doneCallback() callback is fired (if provided) | class="my-animation" |
619
+ *
620
+ * @param {DOMElement} element the element that will be the focus of the move animation
621
+ * @param {DOMElement} parentElement the parentElement element of the element that will be the focus of the move animation
622
+ * @param {DOMElement} afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation
623
+ * @param {function()=} doneCallback the callback function that will be called once the animation is complete
624
+ */
625
+ move : function(element, parentElement, afterElement, doneCallback) {
626
+ cancelChildAnimations(element);
627
+ this.enabled(false, element);
628
+ $delegate.move(element, parentElement, afterElement);
629
+ $rootScope.$$postDigest(function() {
630
+ element = stripCommentsFromElement(element);
631
+ performAnimation('move', 'ng-move', element, parentElement, afterElement, noop, doneCallback);
632
+ });
633
+ },
634
+
635
+ /**
636
+ * @ngdoc method
637
+ * @name $animate#addClass
638
+ *
639
+ * @description
640
+ * Triggers a custom animation event based off the className variable and then attaches the className value to the element as a CSS class.
641
+ * Unlike the other animation methods, the animate service will suffix the className value with {@type -add} in order to provide
642
+ * the animate service the setup and active CSS classes in order to trigger the animation (this will be skipped if no CSS transitions
643
+ * or keyframes are defined on the -add or base CSS class).
644
+ *
645
+ * Below is a breakdown of each step that occurs during addClass animation:
646
+ *
647
+ * | Animation Step | What the element class attribute looks like |
648
+ * |------------------------------------------------------------------------------------------------|---------------------------------------------|
649
+ * | 1. $animate.addClass(element, 'super') is called | class="my-animation" |
650
+ * | 2. $animate runs any JavaScript-defined animations on the element | class="my-animation ng-animate" |
651
+ * | 3. the .super-add class are added to the element | class="my-animation ng-animate super-add" |
652
+ * | 4. $animate scans the element styles to get the CSS transition/animation duration and delay | class="my-animation ng-animate super-add" |
653
+ * | 5. $animate waits for 10ms (this performs a reflow) | class="my-animation ng-animate super-add" |
654
+ * | 6. the .super, .super-add-active and .ng-animate-active classes are added (this triggers the CSS transition/animation) | class="my-animation ng-animate ng-animate-active super super-add super-add-active" |
655
+ * | 7. $animate waits for X milliseconds for the animation to complete | class="my-animation super super-add super-add-active" |
656
+ * | 8. The animation ends and all generated CSS classes are removed from the element | class="my-animation super" |
657
+ * | 9. The super class is kept on the element | class="my-animation super" |
658
+ * | 10. The doneCallback() callback is fired (if provided) | class="my-animation super" |
659
+ *
660
+ * @param {DOMElement} element the element that will be animated
661
+ * @param {string} className the CSS class that will be added to the element and then animated
662
+ * @param {function()=} doneCallback the callback function that will be called once the animation is complete
663
+ */
664
+ addClass : function(element, className, doneCallback) {
665
+ element = stripCommentsFromElement(element);
666
+ performAnimation('addClass', className, element, null, null, function() {
667
+ $delegate.addClass(element, className);
668
+ }, doneCallback);
669
+ },
670
+
671
+ /**
672
+ * @ngdoc method
673
+ * @name $animate#removeClass
674
+ *
675
+ * @description
676
+ * Triggers a custom animation event based off the className variable and then removes the CSS class provided by the className value
677
+ * from the element. Unlike the other animation methods, the animate service will suffix the className value with {@type -remove} in
678
+ * order to provide the animate service the setup and active CSS classes in order to trigger the animation (this will be skipped if
679
+ * no CSS transitions or keyframes are defined on the -remove or base CSS classes).
680
+ *
681
+ * Below is a breakdown of each step that occurs during removeClass animation:
682
+ *
683
+ * | Animation Step | What the element class attribute looks like |
684
+ * |-----------------------------------------------------------------------------------------------|---------------------------------------------|
685
+ * | 1. $animate.removeClass(element, 'super') is called | class="my-animation super" |
686
+ * | 2. $animate runs any JavaScript-defined animations on the element | class="my-animation super ng-animate" |
687
+ * | 3. the .super-remove class are added to the element | class="my-animation super ng-animate super-remove"|
688
+ * | 4. $animate scans the element styles to get the CSS transition/animation duration and delay | class="my-animation super ng-animate super-remove" |
689
+ * | 5. $animate waits for 10ms (this performs a reflow) | class="my-animation super ng-animate super-remove" |
690
+ * | 6. the .super-remove-active and .ng-animate-active classes are added and .super is removed (this triggers the CSS transition/animation) | class="my-animation ng-animate ng-animate-active super-remove super-remove-active" |
691
+ * | 7. $animate waits for X milliseconds for the animation to complete | class="my-animation ng-animate ng-animate-active super-remove super-remove-active" |
692
+ * | 8. The animation ends and all generated CSS classes are removed from the element | class="my-animation" |
693
+ * | 9. The doneCallback() callback is fired (if provided) | class="my-animation" |
694
+ *
695
+ *
696
+ * @param {DOMElement} element the element that will be animated
697
+ * @param {string} className the CSS class that will be animated and then removed from the element
698
+ * @param {function()=} doneCallback the callback function that will be called once the animation is complete
699
+ */
700
+ removeClass : function(element, className, doneCallback) {
701
+ element = stripCommentsFromElement(element);
702
+ performAnimation('removeClass', className, element, null, null, function() {
703
+ $delegate.removeClass(element, className);
704
+ }, doneCallback);
705
+ },
706
+
707
+ /**
708
+ *
709
+ * @ngdoc function
710
+ * @name $animate#setClass
711
+ * @function
712
+ * @description Adds and/or removes the given CSS classes to and from the element.
713
+ * Once complete, the done() callback will be fired (if provided).
714
+ * @param {DOMElement} element the element which will it's CSS classes changed
715
+ * removed from it
716
+ * @param {string} add the CSS classes which will be added to the element
717
+ * @param {string} remove the CSS class which will be removed from the element
718
+ * @param {Function=} done the callback function (if provided) that will be fired after the
719
+ * CSS classes have been set on the element
720
+ */
721
+ setClass : function(element, add, remove, doneCallback) {
722
+ element = stripCommentsFromElement(element);
723
+ performAnimation('setClass', [add, remove], element, null, null, function() {
724
+ $delegate.setClass(element, add, remove);
725
+ }, doneCallback);
726
+ },
727
+
728
+ /**
729
+ * @ngdoc method
730
+ * @name $animate#enabled
731
+ * @function
732
+ *
733
+ * @param {boolean=} value If provided then set the animation on or off.
734
+ * @param {DOMElement=} element If provided then the element will be used to represent the enable/disable operation
735
+ * @return {boolean} Current animation state.
736
+ *
737
+ * @description
738
+ * Globally enables/disables animations.
739
+ *
740
+ */
741
+ enabled : function(value, element) {
742
+ switch(arguments.length) {
743
+ case 2:
744
+ if(value) {
745
+ cleanup(element);
746
+ } else {
747
+ var data = element.data(NG_ANIMATE_STATE) || {};
748
+ data.disabled = true;
749
+ element.data(NG_ANIMATE_STATE, data);
750
+ }
751
+ break;
752
+
753
+ case 1:
754
+ rootAnimateState.disabled = !value;
755
+ break;
756
+
757
+ default:
758
+ value = !rootAnimateState.disabled;
759
+ break;
760
+ }
761
+ return !!value;
762
+ }
763
+ };
764
+
765
+ /*
766
+ all animations call this shared animation triggering function internally.
767
+ The animationEvent variable refers to the JavaScript animation event that will be triggered
768
+ and the className value is the name of the animation that will be applied within the
769
+ CSS code. Element, parentElement and afterElement are provided DOM elements for the animation
770
+ and the onComplete callback will be fired once the animation is fully complete.
771
+ */
772
+ function performAnimation(animationEvent, className, element, parentElement, afterElement, domOperation, doneCallback) {
773
+
774
+ var runner = animationRunner(element, animationEvent, className);
775
+ if(!runner) {
776
+ fireDOMOperation();
777
+ fireBeforeCallbackAsync();
778
+ fireAfterCallbackAsync();
779
+ closeAnimation();
780
+ return;
781
+ }
782
+
783
+ className = runner.className;
784
+ var elementEvents = angular.element._data(runner.node);
785
+ elementEvents = elementEvents && elementEvents.events;
786
+
787
+ if (!parentElement) {
788
+ parentElement = afterElement ? afterElement.parent() : element.parent();
789
+ }
790
+
791
+ var ngAnimateState = element.data(NG_ANIMATE_STATE) || {};
792
+ var runningAnimations = ngAnimateState.active || {};
793
+ var totalActiveAnimations = ngAnimateState.totalActive || 0;
794
+ var lastAnimation = ngAnimateState.last;
795
+
796
+ //only allow animations if the currently running animation is not structural
797
+ //or if there is no animation running at all
798
+ var skipAnimations = runner.isClassBased ?
799
+ ngAnimateState.disabled || (lastAnimation && !lastAnimation.isClassBased) :
800
+ false;
801
+
802
+ //skip the animation if animations are disabled, a parent is already being animated,
803
+ //the element is not currently attached to the document body or then completely close
804
+ //the animation if any matching animations are not found at all.
805
+ //NOTE: IE8 + IE9 should close properly (run closeAnimation()) in case an animation was found.
806
+ if (skipAnimations || animationsDisabled(element, parentElement)) {
807
+ fireDOMOperation();
808
+ fireBeforeCallbackAsync();
809
+ fireAfterCallbackAsync();
810
+ closeAnimation();
811
+ return;
812
+ }
813
+
814
+ var skipAnimation = false;
815
+ if(totalActiveAnimations > 0) {
816
+ var animationsToCancel = [];
817
+ if(!runner.isClassBased) {
818
+ if(animationEvent == 'leave' && runningAnimations['ng-leave']) {
819
+ skipAnimation = true;
820
+ } else {
821
+ //cancel all animations when a structural animation takes place
822
+ for(var klass in runningAnimations) {
823
+ animationsToCancel.push(runningAnimations[klass]);
824
+ cleanup(element, klass);
825
+ }
826
+ runningAnimations = {};
827
+ totalActiveAnimations = 0;
828
+ }
829
+ } else if(lastAnimation.event == 'setClass') {
830
+ animationsToCancel.push(lastAnimation);
831
+ cleanup(element, className);
832
+ }
833
+ else if(runningAnimations[className]) {
834
+ var current = runningAnimations[className];
835
+ if(current.event == animationEvent) {
836
+ skipAnimation = true;
837
+ } else {
838
+ animationsToCancel.push(current);
839
+ cleanup(element, className);
840
+ }
841
+ }
842
+
843
+ if(animationsToCancel.length > 0) {
844
+ forEach(animationsToCancel, function(operation) {
845
+ operation.cancel();
846
+ });
847
+ }
848
+ }
849
+
850
+ if(runner.isClassBased && !runner.isSetClassOperation && !skipAnimation) {
851
+ skipAnimation = (animationEvent == 'addClass') == element.hasClass(className); //opposite of XOR
852
+ }
853
+
854
+ if(skipAnimation) {
855
+ fireBeforeCallbackAsync();
856
+ fireAfterCallbackAsync();
857
+ fireDoneCallbackAsync();
858
+ return;
859
+ }
860
+
861
+ if(animationEvent == 'leave') {
862
+ //there's no need to ever remove the listener since the element
863
+ //will be removed (destroyed) after the leave animation ends or
864
+ //is cancelled midway
865
+ element.one('$destroy', function(e) {
866
+ var element = angular.element(this);
867
+ var state = element.data(NG_ANIMATE_STATE);
868
+ if(state) {
869
+ var activeLeaveAnimation = state.active['ng-leave'];
870
+ if(activeLeaveAnimation) {
871
+ activeLeaveAnimation.cancel();
872
+ cleanup(element, 'ng-leave');
873
+ }
874
+ }
875
+ });
876
+ }
877
+
878
+ //the ng-animate class does nothing, but it's here to allow for
879
+ //parent animations to find and cancel child animations when needed
880
+ element.addClass(NG_ANIMATE_CLASS_NAME);
881
+
882
+ var localAnimationCount = globalAnimationCounter++;
883
+ totalActiveAnimations++;
884
+ runningAnimations[className] = runner;
885
+
886
+ element.data(NG_ANIMATE_STATE, {
887
+ last : runner,
888
+ active : runningAnimations,
889
+ index : localAnimationCount,
890
+ totalActive : totalActiveAnimations
891
+ });
892
+
893
+ //first we run the before animations and when all of those are complete
894
+ //then we perform the DOM operation and run the next set of animations
895
+ fireBeforeCallbackAsync();
896
+ runner.before(function(cancelled) {
897
+ var data = element.data(NG_ANIMATE_STATE);
898
+ cancelled = cancelled ||
899
+ !data || !data.active[className] ||
900
+ (runner.isClassBased && data.active[className].event != animationEvent);
901
+
902
+ fireDOMOperation();
903
+ if(cancelled === true) {
904
+ closeAnimation();
905
+ } else {
906
+ fireAfterCallbackAsync();
907
+ runner.after(closeAnimation);
908
+ }
909
+ });
910
+
911
+ function fireDOMCallback(animationPhase) {
912
+ var eventName = '$animate:' + animationPhase;
913
+ if(elementEvents && elementEvents[eventName] && elementEvents[eventName].length > 0) {
914
+ $$asyncCallback(function() {
915
+ element.triggerHandler(eventName, {
916
+ event : animationEvent,
917
+ className : className
918
+ });
919
+ });
920
+ }
921
+ }
922
+
923
+ function fireBeforeCallbackAsync() {
924
+ fireDOMCallback('before');
925
+ }
926
+
927
+ function fireAfterCallbackAsync() {
928
+ fireDOMCallback('after');
929
+ }
930
+
931
+ function fireDoneCallbackAsync() {
932
+ fireDOMCallback('close');
933
+ if(doneCallback) {
934
+ $$asyncCallback(function() {
935
+ doneCallback();
936
+ });
937
+ }
938
+ }
939
+
940
+ //it is less complicated to use a flag than managing and canceling
941
+ //timeouts containing multiple callbacks.
942
+ function fireDOMOperation() {
943
+ if(!fireDOMOperation.hasBeenRun) {
944
+ fireDOMOperation.hasBeenRun = true;
945
+ domOperation();
946
+ }
947
+ }
948
+
949
+ function closeAnimation() {
950
+ if(!closeAnimation.hasBeenRun) {
951
+ closeAnimation.hasBeenRun = true;
952
+ var data = element.data(NG_ANIMATE_STATE);
953
+ if(data) {
954
+ /* only structural animations wait for reflow before removing an
955
+ animation, but class-based animations don't. An example of this
956
+ failing would be when a parent HTML tag has a ng-class attribute
957
+ causing ALL directives below to skip animations during the digest */
958
+ if(runner && runner.isClassBased) {
959
+ cleanup(element, className);
960
+ } else {
961
+ $$asyncCallback(function() {
962
+ var data = element.data(NG_ANIMATE_STATE) || {};
963
+ if(localAnimationCount == data.index) {
964
+ cleanup(element, className, animationEvent);
965
+ }
966
+ });
967
+ element.data(NG_ANIMATE_STATE, data);
968
+ }
969
+ }
970
+ fireDoneCallbackAsync();
971
+ }
972
+ }
973
+ }
974
+
975
+ function cancelChildAnimations(element) {
976
+ var node = extractElementNode(element);
977
+ if (node) {
978
+ var nodes = angular.isFunction(node.getElementsByClassName) ?
979
+ node.getElementsByClassName(NG_ANIMATE_CLASS_NAME) :
980
+ node.querySelectorAll('.' + NG_ANIMATE_CLASS_NAME);
981
+ forEach(nodes, function(element) {
982
+ element = angular.element(element);
983
+ var data = element.data(NG_ANIMATE_STATE);
984
+ if(data && data.active) {
985
+ forEach(data.active, function(runner) {
986
+ runner.cancel();
987
+ });
988
+ }
989
+ });
990
+ }
991
+ }
992
+
993
+ function cleanup(element, className) {
994
+ if(isMatchingElement(element, $rootElement)) {
995
+ if(!rootAnimateState.disabled) {
996
+ rootAnimateState.running = false;
997
+ rootAnimateState.structural = false;
998
+ }
999
+ } else if(className) {
1000
+ var data = element.data(NG_ANIMATE_STATE) || {};
1001
+
1002
+ var removeAnimations = className === true;
1003
+ if(!removeAnimations && data.active && data.active[className]) {
1004
+ data.totalActive--;
1005
+ delete data.active[className];
1006
+ }
1007
+
1008
+ if(removeAnimations || !data.totalActive) {
1009
+ element.removeClass(NG_ANIMATE_CLASS_NAME);
1010
+ element.removeData(NG_ANIMATE_STATE);
1011
+ }
1012
+ }
1013
+ }
1014
+
1015
+ function animationsDisabled(element, parentElement) {
1016
+ if (rootAnimateState.disabled) return true;
1017
+
1018
+ if(isMatchingElement(element, $rootElement)) {
1019
+ return rootAnimateState.disabled || rootAnimateState.running;
1020
+ }
1021
+
1022
+ do {
1023
+ //the element did not reach the root element which means that it
1024
+ //is not apart of the DOM. Therefore there is no reason to do
1025
+ //any animations on it
1026
+ if(parentElement.length === 0) break;
1027
+
1028
+ var isRoot = isMatchingElement(parentElement, $rootElement);
1029
+ var state = isRoot ? rootAnimateState : parentElement.data(NG_ANIMATE_STATE);
1030
+ var result = state && (!!state.disabled || state.running || state.totalActive > 0);
1031
+ if(isRoot || result) {
1032
+ return result;
1033
+ }
1034
+
1035
+ if(isRoot) return true;
1036
+ }
1037
+ while(parentElement = parentElement.parent());
1038
+
1039
+ return true;
1040
+ }
1041
+ }]);
1042
+
1043
+ $animateProvider.register('', ['$window', '$sniffer', '$timeout', '$$animateReflow',
1044
+ function($window, $sniffer, $timeout, $$animateReflow) {
1045
+ // Detect proper transitionend/animationend event names.
1046
+ var CSS_PREFIX = '', TRANSITION_PROP, TRANSITIONEND_EVENT, ANIMATION_PROP, ANIMATIONEND_EVENT;
1047
+
1048
+ // If unprefixed events are not supported but webkit-prefixed are, use the latter.
1049
+ // Otherwise, just use W3C names, browsers not supporting them at all will just ignore them.
1050
+ // Note: Chrome implements `window.onwebkitanimationend` and doesn't implement `window.onanimationend`
1051
+ // but at the same time dispatches the `animationend` event and not `webkitAnimationEnd`.
1052
+ // Register both events in case `window.onanimationend` is not supported because of that,
1053
+ // do the same for `transitionend` as Safari is likely to exhibit similar behavior.
1054
+ // Also, the only modern browser that uses vendor prefixes for transitions/keyframes is webkit
1055
+ // therefore there is no reason to test anymore for other vendor prefixes: http://caniuse.com/#search=transition
1056
+ if (window.ontransitionend === undefined && window.onwebkittransitionend !== undefined) {
1057
+ CSS_PREFIX = '-webkit-';
1058
+ TRANSITION_PROP = 'WebkitTransition';
1059
+ TRANSITIONEND_EVENT = 'webkitTransitionEnd transitionend';
1060
+ } else {
1061
+ TRANSITION_PROP = 'transition';
1062
+ TRANSITIONEND_EVENT = 'transitionend';
1063
+ }
1064
+
1065
+ if (window.onanimationend === undefined && window.onwebkitanimationend !== undefined) {
1066
+ CSS_PREFIX = '-webkit-';
1067
+ ANIMATION_PROP = 'WebkitAnimation';
1068
+ ANIMATIONEND_EVENT = 'webkitAnimationEnd animationend';
1069
+ } else {
1070
+ ANIMATION_PROP = 'animation';
1071
+ ANIMATIONEND_EVENT = 'animationend';
1072
+ }
1073
+
1074
+ var DURATION_KEY = 'Duration';
1075
+ var PROPERTY_KEY = 'Property';
1076
+ var DELAY_KEY = 'Delay';
1077
+ var ANIMATION_ITERATION_COUNT_KEY = 'IterationCount';
1078
+ var NG_ANIMATE_PARENT_KEY = '$$ngAnimateKey';
1079
+ var NG_ANIMATE_CSS_DATA_KEY = '$$ngAnimateCSS3Data';
1080
+ var NG_ANIMATE_BLOCK_CLASS_NAME = 'ng-animate-block-transitions';
1081
+ var ELAPSED_TIME_MAX_DECIMAL_PLACES = 3;
1082
+ var CLOSING_TIME_BUFFER = 1.5;
1083
+ var ONE_SECOND = 1000;
1084
+
1085
+ var lookupCache = {};
1086
+ var parentCounter = 0;
1087
+ var animationReflowQueue = [];
1088
+ var cancelAnimationReflow;
1089
+ function afterReflow(element, callback) {
1090
+ if(cancelAnimationReflow) {
1091
+ cancelAnimationReflow();
1092
+ }
1093
+ animationReflowQueue.push(callback);
1094
+ cancelAnimationReflow = $$animateReflow(function() {
1095
+ forEach(animationReflowQueue, function(fn) {
1096
+ fn();
1097
+ });
1098
+
1099
+ animationReflowQueue = [];
1100
+ cancelAnimationReflow = null;
1101
+ lookupCache = {};
1102
+ });
1103
+ }
1104
+
1105
+ var closingTimer = null;
1106
+ var closingTimestamp = 0;
1107
+ var animationElementQueue = [];
1108
+ function animationCloseHandler(element, totalTime) {
1109
+ var node = extractElementNode(element);
1110
+ element = angular.element(node);
1111
+
1112
+ //this item will be garbage collected by the closing
1113
+ //animation timeout
1114
+ animationElementQueue.push(element);
1115
+
1116
+ //but it may not need to cancel out the existing timeout
1117
+ //if the timestamp is less than the previous one
1118
+ var futureTimestamp = Date.now() + (totalTime * 1000);
1119
+ if(futureTimestamp <= closingTimestamp) {
1120
+ return;
1121
+ }
1122
+
1123
+ $timeout.cancel(closingTimer);
1124
+
1125
+ closingTimestamp = futureTimestamp;
1126
+ closingTimer = $timeout(function() {
1127
+ closeAllAnimations(animationElementQueue);
1128
+ animationElementQueue = [];
1129
+ }, totalTime, false);
1130
+ }
1131
+
1132
+ function closeAllAnimations(elements) {
1133
+ forEach(elements, function(element) {
1134
+ var elementData = element.data(NG_ANIMATE_CSS_DATA_KEY);
1135
+ if(elementData) {
1136
+ (elementData.closeAnimationFn || noop)();
1137
+ }
1138
+ });
1139
+ }
1140
+
1141
+ function getElementAnimationDetails(element, cacheKey) {
1142
+ var data = cacheKey ? lookupCache[cacheKey] : null;
1143
+ if(!data) {
1144
+ var transitionDuration = 0;
1145
+ var transitionDelay = 0;
1146
+ var animationDuration = 0;
1147
+ var animationDelay = 0;
1148
+ var transitionDelayStyle;
1149
+ var animationDelayStyle;
1150
+ var transitionDurationStyle;
1151
+ var transitionPropertyStyle;
1152
+
1153
+ //we want all the styles defined before and after
1154
+ forEach(element, function(element) {
1155
+ if (element.nodeType == ELEMENT_NODE) {
1156
+ var elementStyles = $window.getComputedStyle(element) || {};
1157
+
1158
+ transitionDurationStyle = elementStyles[TRANSITION_PROP + DURATION_KEY];
1159
+
1160
+ transitionDuration = Math.max(parseMaxTime(transitionDurationStyle), transitionDuration);
1161
+
1162
+ transitionPropertyStyle = elementStyles[TRANSITION_PROP + PROPERTY_KEY];
1163
+
1164
+ transitionDelayStyle = elementStyles[TRANSITION_PROP + DELAY_KEY];
1165
+
1166
+ transitionDelay = Math.max(parseMaxTime(transitionDelayStyle), transitionDelay);
1167
+
1168
+ animationDelayStyle = elementStyles[ANIMATION_PROP + DELAY_KEY];
1169
+
1170
+ animationDelay = Math.max(parseMaxTime(animationDelayStyle), animationDelay);
1171
+
1172
+ var aDuration = parseMaxTime(elementStyles[ANIMATION_PROP + DURATION_KEY]);
1173
+
1174
+ if(aDuration > 0) {
1175
+ aDuration *= parseInt(elementStyles[ANIMATION_PROP + ANIMATION_ITERATION_COUNT_KEY], 10) || 1;
1176
+ }
1177
+
1178
+ animationDuration = Math.max(aDuration, animationDuration);
1179
+ }
1180
+ });
1181
+ data = {
1182
+ total : 0,
1183
+ transitionPropertyStyle: transitionPropertyStyle,
1184
+ transitionDurationStyle: transitionDurationStyle,
1185
+ transitionDelayStyle: transitionDelayStyle,
1186
+ transitionDelay: transitionDelay,
1187
+ transitionDuration: transitionDuration,
1188
+ animationDelayStyle: animationDelayStyle,
1189
+ animationDelay: animationDelay,
1190
+ animationDuration: animationDuration
1191
+ };
1192
+ if(cacheKey) {
1193
+ lookupCache[cacheKey] = data;
1194
+ }
1195
+ }
1196
+ return data;
1197
+ }
1198
+
1199
+ function parseMaxTime(str) {
1200
+ var maxValue = 0;
1201
+ var values = angular.isString(str) ?
1202
+ str.split(/\s*,\s*/) :
1203
+ [];
1204
+ forEach(values, function(value) {
1205
+ maxValue = Math.max(parseFloat(value) || 0, maxValue);
1206
+ });
1207
+ return maxValue;
1208
+ }
1209
+
1210
+ function getCacheKey(element) {
1211
+ var parentElement = element.parent();
1212
+ var parentID = parentElement.data(NG_ANIMATE_PARENT_KEY);
1213
+ if(!parentID) {
1214
+ parentElement.data(NG_ANIMATE_PARENT_KEY, ++parentCounter);
1215
+ parentID = parentCounter;
1216
+ }
1217
+ return parentID + '-' + extractElementNode(element).className;
1218
+ }
1219
+
1220
+ function animateSetup(animationEvent, element, className, calculationDecorator) {
1221
+ var cacheKey = getCacheKey(element);
1222
+ var eventCacheKey = cacheKey + ' ' + className;
1223
+ var itemIndex = lookupCache[eventCacheKey] ? ++lookupCache[eventCacheKey].total : 0;
1224
+
1225
+ var stagger = {};
1226
+ if(itemIndex > 0) {
1227
+ var staggerClassName = className + '-stagger';
1228
+ var staggerCacheKey = cacheKey + ' ' + staggerClassName;
1229
+ var applyClasses = !lookupCache[staggerCacheKey];
1230
+
1231
+ applyClasses && element.addClass(staggerClassName);
1232
+
1233
+ stagger = getElementAnimationDetails(element, staggerCacheKey);
1234
+
1235
+ applyClasses && element.removeClass(staggerClassName);
1236
+ }
1237
+
1238
+ /* the animation itself may need to add/remove special CSS classes
1239
+ * before calculating the anmation styles */
1240
+ calculationDecorator = calculationDecorator ||
1241
+ function(fn) { return fn(); };
1242
+
1243
+ element.addClass(className);
1244
+
1245
+ var formerData = element.data(NG_ANIMATE_CSS_DATA_KEY) || {};
1246
+
1247
+ var timings = calculationDecorator(function() {
1248
+ return getElementAnimationDetails(element, eventCacheKey);
1249
+ });
1250
+
1251
+ var transitionDuration = timings.transitionDuration;
1252
+ var animationDuration = timings.animationDuration;
1253
+ if(transitionDuration === 0 && animationDuration === 0) {
1254
+ element.removeClass(className);
1255
+ return false;
1256
+ }
1257
+
1258
+ element.data(NG_ANIMATE_CSS_DATA_KEY, {
1259
+ running : formerData.running || 0,
1260
+ itemIndex : itemIndex,
1261
+ stagger : stagger,
1262
+ timings : timings,
1263
+ closeAnimationFn : noop
1264
+ });
1265
+
1266
+ //temporarily disable the transition so that the enter styles
1267
+ //don't animate twice (this is here to avoid a bug in Chrome/FF).
1268
+ var isCurrentlyAnimating = formerData.running > 0 || animationEvent == 'setClass';
1269
+ if(transitionDuration > 0) {
1270
+ blockTransitions(element, className, isCurrentlyAnimating);
1271
+ }
1272
+
1273
+ //staggering keyframe animations work by adjusting the `animation-delay` CSS property
1274
+ //on the given element, however, the delay value can only calculated after the reflow
1275
+ //since by that time $animate knows how many elements are being animated. Therefore,
1276
+ //until the reflow occurs the element needs to be blocked (where the keyframe animation
1277
+ //is set to `none 0s`). This blocking mechanism should only be set for when a stagger
1278
+ //animation is detected and when the element item index is greater than 0.
1279
+ if(animationDuration > 0 && stagger.animationDelay > 0 && stagger.animationDuration === 0) {
1280
+ blockKeyframeAnimations(element);
1281
+ }
1282
+
1283
+ return true;
1284
+ }
1285
+
1286
+ function isStructuralAnimation(className) {
1287
+ return className == 'ng-enter' || className == 'ng-move' || className == 'ng-leave';
1288
+ }
1289
+
1290
+ function blockTransitions(element, className, isAnimating) {
1291
+ if(isStructuralAnimation(className) || !isAnimating) {
1292
+ extractElementNode(element).style[TRANSITION_PROP + PROPERTY_KEY] = 'none';
1293
+ } else {
1294
+ element.addClass(NG_ANIMATE_BLOCK_CLASS_NAME);
1295
+ }
1296
+ }
1297
+
1298
+ function blockKeyframeAnimations(element) {
1299
+ extractElementNode(element).style[ANIMATION_PROP] = 'none 0s';
1300
+ }
1301
+
1302
+ function unblockTransitions(element, className) {
1303
+ var prop = TRANSITION_PROP + PROPERTY_KEY;
1304
+ var node = extractElementNode(element);
1305
+ if(node.style[prop] && node.style[prop].length > 0) {
1306
+ node.style[prop] = '';
1307
+ }
1308
+ element.removeClass(NG_ANIMATE_BLOCK_CLASS_NAME);
1309
+ }
1310
+
1311
+ function unblockKeyframeAnimations(element) {
1312
+ var prop = ANIMATION_PROP;
1313
+ var node = extractElementNode(element);
1314
+ if(node.style[prop] && node.style[prop].length > 0) {
1315
+ node.style[prop] = '';
1316
+ }
1317
+ }
1318
+
1319
+ function animateRun(animationEvent, element, className, activeAnimationComplete) {
1320
+ var node = extractElementNode(element);
1321
+ var elementData = element.data(NG_ANIMATE_CSS_DATA_KEY);
1322
+ if(node.className.indexOf(className) == -1 || !elementData) {
1323
+ activeAnimationComplete();
1324
+ return;
1325
+ }
1326
+
1327
+ var activeClassName = '';
1328
+ forEach(className.split(' '), function(klass, i) {
1329
+ activeClassName += (i > 0 ? ' ' : '') + klass + '-active';
1330
+ });
1331
+
1332
+ var stagger = elementData.stagger;
1333
+ var timings = elementData.timings;
1334
+ var itemIndex = elementData.itemIndex;
1335
+ var maxDuration = Math.max(timings.transitionDuration, timings.animationDuration);
1336
+ var maxDelay = Math.max(timings.transitionDelay, timings.animationDelay);
1337
+ var maxDelayTime = maxDelay * ONE_SECOND;
1338
+
1339
+ var startTime = Date.now();
1340
+ var css3AnimationEvents = ANIMATIONEND_EVENT + ' ' + TRANSITIONEND_EVENT;
1341
+
1342
+ var style = '', appliedStyles = [];
1343
+ if(timings.transitionDuration > 0) {
1344
+ var propertyStyle = timings.transitionPropertyStyle;
1345
+ if(propertyStyle.indexOf('all') == -1) {
1346
+ style += CSS_PREFIX + 'transition-property: ' + propertyStyle + ';';
1347
+ style += CSS_PREFIX + 'transition-duration: ' + timings.transitionDurationStyle + ';';
1348
+ appliedStyles.push(CSS_PREFIX + 'transition-property');
1349
+ appliedStyles.push(CSS_PREFIX + 'transition-duration');
1350
+ }
1351
+ }
1352
+
1353
+ if(itemIndex > 0) {
1354
+ if(stagger.transitionDelay > 0 && stagger.transitionDuration === 0) {
1355
+ var delayStyle = timings.transitionDelayStyle;
1356
+ style += CSS_PREFIX + 'transition-delay: ' +
1357
+ prepareStaggerDelay(delayStyle, stagger.transitionDelay, itemIndex) + '; ';
1358
+ appliedStyles.push(CSS_PREFIX + 'transition-delay');
1359
+ }
1360
+
1361
+ if(stagger.animationDelay > 0 && stagger.animationDuration === 0) {
1362
+ style += CSS_PREFIX + 'animation-delay: ' +
1363
+ prepareStaggerDelay(timings.animationDelayStyle, stagger.animationDelay, itemIndex) + '; ';
1364
+ appliedStyles.push(CSS_PREFIX + 'animation-delay');
1365
+ }
1366
+ }
1367
+
1368
+ if(appliedStyles.length > 0) {
1369
+ //the element being animated may sometimes contain comment nodes in
1370
+ //the jqLite object, so we're safe to use a single variable to house
1371
+ //the styles since there is always only one element being animated
1372
+ var oldStyle = node.getAttribute('style') || '';
1373
+ node.setAttribute('style', oldStyle + ' ' + style);
1374
+ }
1375
+
1376
+ element.on(css3AnimationEvents, onAnimationProgress);
1377
+ element.addClass(activeClassName);
1378
+ elementData.closeAnimationFn = function() {
1379
+ onEnd();
1380
+ activeAnimationComplete();
1381
+ };
1382
+
1383
+ var staggerTime = itemIndex * (Math.max(stagger.animationDelay, stagger.transitionDelay) || 0);
1384
+ var animationTime = (maxDelay + maxDuration) * CLOSING_TIME_BUFFER;
1385
+ var totalTime = (staggerTime + animationTime) * ONE_SECOND;
1386
+
1387
+ elementData.running++;
1388
+ animationCloseHandler(element, totalTime);
1389
+ return onEnd;
1390
+
1391
+ // This will automatically be called by $animate so
1392
+ // there is no need to attach this internally to the
1393
+ // timeout done method.
1394
+ function onEnd(cancelled) {
1395
+ element.off(css3AnimationEvents, onAnimationProgress);
1396
+ element.removeClass(activeClassName);
1397
+ animateClose(element, className);
1398
+ var node = extractElementNode(element);
1399
+ for (var i in appliedStyles) {
1400
+ node.style.removeProperty(appliedStyles[i]);
1401
+ }
1402
+ }
1403
+
1404
+ function onAnimationProgress(event) {
1405
+ event.stopPropagation();
1406
+ var ev = event.originalEvent || event;
1407
+ var timeStamp = ev.$manualTimeStamp || ev.timeStamp || Date.now();
1408
+
1409
+ /* Firefox (or possibly just Gecko) likes to not round values up
1410
+ * when a ms measurement is used for the animation */
1411
+ var elapsedTime = parseFloat(ev.elapsedTime.toFixed(ELAPSED_TIME_MAX_DECIMAL_PLACES));
1412
+
1413
+ /* $manualTimeStamp is a mocked timeStamp value which is set
1414
+ * within browserTrigger(). This is only here so that tests can
1415
+ * mock animations properly. Real events fallback to event.timeStamp,
1416
+ * or, if they don't, then a timeStamp is automatically created for them.
1417
+ * We're checking to see if the timeStamp surpasses the expected delay,
1418
+ * but we're using elapsedTime instead of the timeStamp on the 2nd
1419
+ * pre-condition since animations sometimes close off early */
1420
+ if(Math.max(timeStamp - startTime, 0) >= maxDelayTime && elapsedTime >= maxDuration) {
1421
+ activeAnimationComplete();
1422
+ }
1423
+ }
1424
+ }
1425
+
1426
+ function prepareStaggerDelay(delayStyle, staggerDelay, index) {
1427
+ var style = '';
1428
+ forEach(delayStyle.split(','), function(val, i) {
1429
+ style += (i > 0 ? ',' : '') +
1430
+ (index * staggerDelay + parseInt(val, 10)) + 's';
1431
+ });
1432
+ return style;
1433
+ }
1434
+
1435
+ function animateBefore(animationEvent, element, className, calculationDecorator) {
1436
+ if(animateSetup(animationEvent, element, className, calculationDecorator)) {
1437
+ return function(cancelled) {
1438
+ cancelled && animateClose(element, className);
1439
+ };
1440
+ }
1441
+ }
1442
+
1443
+ function animateAfter(animationEvent, element, className, afterAnimationComplete) {
1444
+ if(element.data(NG_ANIMATE_CSS_DATA_KEY)) {
1445
+ return animateRun(animationEvent, element, className, afterAnimationComplete);
1446
+ } else {
1447
+ animateClose(element, className);
1448
+ afterAnimationComplete();
1449
+ }
1450
+ }
1451
+
1452
+ function animate(animationEvent, element, className, animationComplete) {
1453
+ //If the animateSetup function doesn't bother returning a
1454
+ //cancellation function then it means that there is no animation
1455
+ //to perform at all
1456
+ var preReflowCancellation = animateBefore(animationEvent, element, className);
1457
+ if(!preReflowCancellation) {
1458
+ animationComplete();
1459
+ return;
1460
+ }
1461
+
1462
+ //There are two cancellation functions: one is before the first
1463
+ //reflow animation and the second is during the active state
1464
+ //animation. The first function will take care of removing the
1465
+ //data from the element which will not make the 2nd animation
1466
+ //happen in the first place
1467
+ var cancel = preReflowCancellation;
1468
+ afterReflow(element, function() {
1469
+ unblockTransitions(element, className);
1470
+ unblockKeyframeAnimations(element);
1471
+ //once the reflow is complete then we point cancel to
1472
+ //the new cancellation function which will remove all of the
1473
+ //animation properties from the active animation
1474
+ cancel = animateAfter(animationEvent, element, className, animationComplete);
1475
+ });
1476
+
1477
+ return function(cancelled) {
1478
+ (cancel || noop)(cancelled);
1479
+ };
1480
+ }
1481
+
1482
+ function animateClose(element, className) {
1483
+ element.removeClass(className);
1484
+ var data = element.data(NG_ANIMATE_CSS_DATA_KEY);
1485
+ if(data) {
1486
+ if(data.running) {
1487
+ data.running--;
1488
+ }
1489
+ if(!data.running || data.running === 0) {
1490
+ element.removeData(NG_ANIMATE_CSS_DATA_KEY);
1491
+ }
1492
+ }
1493
+ }
1494
+
1495
+ return {
1496
+ enter : function(element, animationCompleted) {
1497
+ return animate('enter', element, 'ng-enter', animationCompleted);
1498
+ },
1499
+
1500
+ leave : function(element, animationCompleted) {
1501
+ return animate('leave', element, 'ng-leave', animationCompleted);
1502
+ },
1503
+
1504
+ move : function(element, animationCompleted) {
1505
+ return animate('move', element, 'ng-move', animationCompleted);
1506
+ },
1507
+
1508
+ beforeSetClass : function(element, add, remove, animationCompleted) {
1509
+ var className = suffixClasses(remove, '-remove') + ' ' +
1510
+ suffixClasses(add, '-add');
1511
+ var cancellationMethod = animateBefore('setClass', element, className, function(fn) {
1512
+ /* when classes are removed from an element then the transition style
1513
+ * that is applied is the transition defined on the element without the
1514
+ * CSS class being there. This is how CSS3 functions outside of ngAnimate.
1515
+ * http://plnkr.co/edit/j8OzgTNxHTb4n3zLyjGW?p=preview */
1516
+ var klass = element.attr('class');
1517
+ element.removeClass(remove);
1518
+ element.addClass(add);
1519
+ var timings = fn();
1520
+ element.attr('class', klass);
1521
+ return timings;
1522
+ });
1523
+
1524
+ if(cancellationMethod) {
1525
+ afterReflow(element, function() {
1526
+ unblockTransitions(element, className);
1527
+ unblockKeyframeAnimations(element);
1528
+ animationCompleted();
1529
+ });
1530
+ return cancellationMethod;
1531
+ }
1532
+ animationCompleted();
1533
+ },
1534
+
1535
+ beforeAddClass : function(element, className, animationCompleted) {
1536
+ var cancellationMethod = animateBefore('addClass', element, suffixClasses(className, '-add'), function(fn) {
1537
+
1538
+ /* when a CSS class is added to an element then the transition style that
1539
+ * is applied is the transition defined on the element when the CSS class
1540
+ * is added at the time of the animation. This is how CSS3 functions
1541
+ * outside of ngAnimate. */
1542
+ element.addClass(className);
1543
+ var timings = fn();
1544
+ element.removeClass(className);
1545
+ return timings;
1546
+ });
1547
+
1548
+ if(cancellationMethod) {
1549
+ afterReflow(element, function() {
1550
+ unblockTransitions(element, className);
1551
+ unblockKeyframeAnimations(element);
1552
+ animationCompleted();
1553
+ });
1554
+ return cancellationMethod;
1555
+ }
1556
+ animationCompleted();
1557
+ },
1558
+
1559
+ setClass : function(element, add, remove, animationCompleted) {
1560
+ remove = suffixClasses(remove, '-remove');
1561
+ add = suffixClasses(add, '-add');
1562
+ var className = remove + ' ' + add;
1563
+ return animateAfter('setClass', element, className, animationCompleted);
1564
+ },
1565
+
1566
+ addClass : function(element, className, animationCompleted) {
1567
+ return animateAfter('addClass', element, suffixClasses(className, '-add'), animationCompleted);
1568
+ },
1569
+
1570
+ beforeRemoveClass : function(element, className, animationCompleted) {
1571
+ var cancellationMethod = animateBefore('removeClass', element, suffixClasses(className, '-remove'), function(fn) {
1572
+ /* when classes are removed from an element then the transition style
1573
+ * that is applied is the transition defined on the element without the
1574
+ * CSS class being there. This is how CSS3 functions outside of ngAnimate.
1575
+ * http://plnkr.co/edit/j8OzgTNxHTb4n3zLyjGW?p=preview */
1576
+ var klass = element.attr('class');
1577
+ element.removeClass(className);
1578
+ var timings = fn();
1579
+ element.attr('class', klass);
1580
+ return timings;
1581
+ });
1582
+
1583
+ if(cancellationMethod) {
1584
+ afterReflow(element, function() {
1585
+ unblockTransitions(element, className);
1586
+ unblockKeyframeAnimations(element);
1587
+ animationCompleted();
1588
+ });
1589
+ return cancellationMethod;
1590
+ }
1591
+ animationCompleted();
1592
+ },
1593
+
1594
+ removeClass : function(element, className, animationCompleted) {
1595
+ return animateAfter('removeClass', element, suffixClasses(className, '-remove'), animationCompleted);
1596
+ }
1597
+ };
1598
+
1599
+ function suffixClasses(classes, suffix) {
1600
+ var className = '';
1601
+ classes = angular.isArray(classes) ? classes : classes.split(/\s+/);
1602
+ forEach(classes, function(klass, i) {
1603
+ if(klass && klass.length > 0) {
1604
+ className += (i > 0 ? ' ' : '') + klass + suffix;
1605
+ }
1606
+ });
1607
+ return className;
1608
+ }
1609
+ }]);
1610
+ }]);
1611
+
1612
+
1613
+ })(window, window.angular);