angular-gem 1.2.13 → 1.2.14

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
- NDJkZjcyYzg4NDUwZDhkZjNmNGExZGE0MzExY2Q1ZDM3YmJhOTJkMA==
4
+ OWQ0ODc4MjljYTMyODIyMTU1YTJlZTBmNjA5MmQwMmQ4NjEzYzNlNA==
5
5
  data.tar.gz: !binary |-
6
- YzE3MWUyZjk1NzE5NTNmMGEyODI4NDRiM2IwMWQwYmY4MjhiYWVkOQ==
6
+ ZmY3NjA0Y2QxMTMyNGE1MTAyYjUwZDkxZDQ5ZjdiNTMwYmJlMzQ3Zg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YjJmYjBjODRlYWJhMmUwNzFiMTIzMjFmZjU5MzExYzRkYjQyMDdjY2I3MGYx
10
- YjQ3Njg0ZWQzODUxMjQ4ZjllZjAyMmFhZWZjOTE3MzZkZDNmOTAzZjZjODA0
11
- MjYzMTAxOWU5NzUwNzcyZmMxYjcwZjgyOTRhM2QzNDEyNjI0ZTQ=
9
+ NjgyNGZlZDgzZDlhNGU1YmMwMmZlMzE3NGNkNmYwNWVlNmE1Y2RhNmQyMzli
10
+ MDExY2JmYTYyNDA3NDQxZmVkMmZlYTI5OTAxYTg0ZGRhNWYyODRhZWExYTg2
11
+ MzJhZjljZjJhMzk3ZTRjN2M2M2Q3NzVhMGQ0NGJhZTk4MjhkMWI=
12
12
  data.tar.gz: !binary |-
13
- YjQ1MTI1MDg5OGU5YTI3YWVjZThmZjBhZjE3NGMwMGRlZGQxNjM2NTllZGU3
14
- YjFlNjkwZmU5YWNjMDBhNzU2NDZkOTZkZjE5OTRjMGMyODBlMGVjN2MwZDBj
15
- YTUyZTM3MjdiZTViNDAwODlmMTYyYTFlNDljYTY3OTFjNTIxMTY=
13
+ Y2NkODMzMjI4MTY0YTU0MDJmMTZhNjUzMDQxMjJmMmE4MzYzOTM0ODA4YzM3
14
+ NjBhMzI4YjA5YWI1NDY1YmU1OWJhZjViNDdhODlhYjQyZGZiNjQzMTI2MThk
15
+ MDQ1NGEzYjEzZDQxOWI3NGU2ZjAzNzhhYzAyZjljNTE5MmFiMjk=
@@ -1,3 +1,3 @@
1
1
  module AngularGem
2
- VERSION = "1.2.13"
2
+ VERSION = "1.2.14"
3
3
  end
@@ -0,0 +1,1614 @@
1
+ /**
2
+ * @license AngularJS v1.2.14
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 ng.$animate#setClass
711
+ * @methodOf ng.$animate
712
+ * @function
713
+ * @description Adds and/or removes the given CSS classes to and from the element.
714
+ * Once complete, the done() callback will be fired (if provided).
715
+ * @param {DOMElement} element the element which will it's CSS classes changed
716
+ * removed from it
717
+ * @param {string} add the CSS classes which will be added to the element
718
+ * @param {string} remove the CSS class which will be removed from the element
719
+ * @param {Function=} done the callback function (if provided) that will be fired after the
720
+ * CSS classes have been set on the element
721
+ */
722
+ setClass : function(element, add, remove, doneCallback) {
723
+ element = stripCommentsFromElement(element);
724
+ performAnimation('setClass', [add, remove], element, null, null, function() {
725
+ $delegate.setClass(element, add, remove);
726
+ }, doneCallback);
727
+ },
728
+
729
+ /**
730
+ * @ngdoc method
731
+ * @name $animate#enabled
732
+ * @function
733
+ *
734
+ * @param {boolean=} value If provided then set the animation on or off.
735
+ * @param {DOMElement=} element If provided then the element will be used to represent the enable/disable operation
736
+ * @return {boolean} Current animation state.
737
+ *
738
+ * @description
739
+ * Globally enables/disables animations.
740
+ *
741
+ */
742
+ enabled : function(value, element) {
743
+ switch(arguments.length) {
744
+ case 2:
745
+ if(value) {
746
+ cleanup(element);
747
+ } else {
748
+ var data = element.data(NG_ANIMATE_STATE) || {};
749
+ data.disabled = true;
750
+ element.data(NG_ANIMATE_STATE, data);
751
+ }
752
+ break;
753
+
754
+ case 1:
755
+ rootAnimateState.disabled = !value;
756
+ break;
757
+
758
+ default:
759
+ value = !rootAnimateState.disabled;
760
+ break;
761
+ }
762
+ return !!value;
763
+ }
764
+ };
765
+
766
+ /*
767
+ all animations call this shared animation triggering function internally.
768
+ The animationEvent variable refers to the JavaScript animation event that will be triggered
769
+ and the className value is the name of the animation that will be applied within the
770
+ CSS code. Element, parentElement and afterElement are provided DOM elements for the animation
771
+ and the onComplete callback will be fired once the animation is fully complete.
772
+ */
773
+ function performAnimation(animationEvent, className, element, parentElement, afterElement, domOperation, doneCallback) {
774
+
775
+ var runner = animationRunner(element, animationEvent, className);
776
+ if(!runner) {
777
+ fireDOMOperation();
778
+ fireBeforeCallbackAsync();
779
+ fireAfterCallbackAsync();
780
+ fireDoneCallbackAsync();
781
+ return;
782
+ }
783
+
784
+ className = runner.className;
785
+ var elementEvents = angular.element._data(runner.node);
786
+ elementEvents = elementEvents && elementEvents.events;
787
+
788
+ if (!parentElement) {
789
+ parentElement = afterElement ? afterElement.parent() : element.parent();
790
+ }
791
+
792
+ var ngAnimateState = element.data(NG_ANIMATE_STATE) || {};
793
+ var runningAnimations = ngAnimateState.active || {};
794
+ var totalActiveAnimations = ngAnimateState.totalActive || 0;
795
+ var lastAnimation = ngAnimateState.last;
796
+
797
+ //only allow animations if the currently running animation is not structural
798
+ //or if there is no animation running at all
799
+ var skipAnimations = runner.isClassBased ?
800
+ ngAnimateState.disabled || (lastAnimation && !lastAnimation.isClassBased) :
801
+ false;
802
+
803
+ //skip the animation if animations are disabled, a parent is already being animated,
804
+ //the element is not currently attached to the document body or then completely close
805
+ //the animation if any matching animations are not found at all.
806
+ //NOTE: IE8 + IE9 should close properly (run closeAnimation()) in case an animation was found.
807
+ if (skipAnimations || animationsDisabled(element, parentElement)) {
808
+ fireDOMOperation();
809
+ fireBeforeCallbackAsync();
810
+ fireAfterCallbackAsync();
811
+ closeAnimation();
812
+ return;
813
+ }
814
+
815
+ var skipAnimation = false;
816
+ if(totalActiveAnimations > 0) {
817
+ var animationsToCancel = [];
818
+ if(!runner.isClassBased) {
819
+ if(animationEvent == 'leave' && runningAnimations['ng-leave']) {
820
+ skipAnimation = true;
821
+ } else {
822
+ //cancel all animations when a structural animation takes place
823
+ for(var klass in runningAnimations) {
824
+ animationsToCancel.push(runningAnimations[klass]);
825
+ cleanup(element, klass);
826
+ }
827
+ runningAnimations = {};
828
+ totalActiveAnimations = 0;
829
+ }
830
+ } else if(lastAnimation.event == 'setClass') {
831
+ animationsToCancel.push(lastAnimation);
832
+ cleanup(element, className);
833
+ }
834
+ else if(runningAnimations[className]) {
835
+ var current = runningAnimations[className];
836
+ if(current.event == animationEvent) {
837
+ skipAnimation = true;
838
+ } else {
839
+ animationsToCancel.push(current);
840
+ cleanup(element, className);
841
+ }
842
+ }
843
+
844
+ if(animationsToCancel.length > 0) {
845
+ forEach(animationsToCancel, function(operation) {
846
+ operation.cancel();
847
+ });
848
+ }
849
+ }
850
+
851
+ if(runner.isClassBased && !runner.isSetClassOperation && !skipAnimation) {
852
+ skipAnimation = (animationEvent == 'addClass') == element.hasClass(className); //opposite of XOR
853
+ }
854
+
855
+ if(skipAnimation) {
856
+ fireBeforeCallbackAsync();
857
+ fireAfterCallbackAsync();
858
+ fireDoneCallbackAsync();
859
+ return;
860
+ }
861
+
862
+ if(animationEvent == 'leave') {
863
+ //there's no need to ever remove the listener since the element
864
+ //will be removed (destroyed) after the leave animation ends or
865
+ //is cancelled midway
866
+ element.one('$destroy', function(e) {
867
+ var element = angular.element(this);
868
+ var state = element.data(NG_ANIMATE_STATE);
869
+ if(state) {
870
+ var activeLeaveAnimation = state.active['ng-leave'];
871
+ if(activeLeaveAnimation) {
872
+ activeLeaveAnimation.cancel();
873
+ cleanup(element, 'ng-leave');
874
+ }
875
+ }
876
+ });
877
+ }
878
+
879
+ //the ng-animate class does nothing, but it's here to allow for
880
+ //parent animations to find and cancel child animations when needed
881
+ element.addClass(NG_ANIMATE_CLASS_NAME);
882
+
883
+ var localAnimationCount = globalAnimationCounter++;
884
+ totalActiveAnimations++;
885
+ runningAnimations[className] = runner;
886
+
887
+ element.data(NG_ANIMATE_STATE, {
888
+ last : runner,
889
+ active : runningAnimations,
890
+ index : localAnimationCount,
891
+ totalActive : totalActiveAnimations
892
+ });
893
+
894
+ //first we run the before animations and when all of those are complete
895
+ //then we perform the DOM operation and run the next set of animations
896
+ fireBeforeCallbackAsync();
897
+ runner.before(function(cancelled) {
898
+ var data = element.data(NG_ANIMATE_STATE);
899
+ cancelled = cancelled ||
900
+ !data || !data.active[className] ||
901
+ (runner.isClassBased && data.active[className].event != animationEvent);
902
+
903
+ fireDOMOperation();
904
+ if(cancelled === true) {
905
+ closeAnimation();
906
+ } else {
907
+ fireAfterCallbackAsync();
908
+ runner.after(closeAnimation);
909
+ }
910
+ });
911
+
912
+ function fireDOMCallback(animationPhase) {
913
+ var eventName = '$animate:' + animationPhase;
914
+ if(elementEvents && elementEvents[eventName] && elementEvents[eventName].length > 0) {
915
+ $$asyncCallback(function() {
916
+ element.triggerHandler(eventName, {
917
+ event : animationEvent,
918
+ className : className
919
+ });
920
+ });
921
+ }
922
+ }
923
+
924
+ function fireBeforeCallbackAsync() {
925
+ fireDOMCallback('before');
926
+ }
927
+
928
+ function fireAfterCallbackAsync() {
929
+ fireDOMCallback('after');
930
+ }
931
+
932
+ function fireDoneCallbackAsync() {
933
+ fireDOMCallback('close');
934
+ if(doneCallback) {
935
+ $$asyncCallback(function() {
936
+ doneCallback();
937
+ });
938
+ }
939
+ }
940
+
941
+ //it is less complicated to use a flag than managing and canceling
942
+ //timeouts containing multiple callbacks.
943
+ function fireDOMOperation() {
944
+ if(!fireDOMOperation.hasBeenRun) {
945
+ fireDOMOperation.hasBeenRun = true;
946
+ domOperation();
947
+ }
948
+ }
949
+
950
+ function closeAnimation() {
951
+ if(!closeAnimation.hasBeenRun) {
952
+ closeAnimation.hasBeenRun = true;
953
+ var data = element.data(NG_ANIMATE_STATE);
954
+ if(data) {
955
+ /* only structural animations wait for reflow before removing an
956
+ animation, but class-based animations don't. An example of this
957
+ failing would be when a parent HTML tag has a ng-class attribute
958
+ causing ALL directives below to skip animations during the digest */
959
+ if(runner.isClassBased) {
960
+ cleanup(element, className);
961
+ } else {
962
+ $$asyncCallback(function() {
963
+ var data = element.data(NG_ANIMATE_STATE) || {};
964
+ if(localAnimationCount == data.index) {
965
+ cleanup(element, className, animationEvent);
966
+ }
967
+ });
968
+ element.data(NG_ANIMATE_STATE, data);
969
+ }
970
+ }
971
+ fireDoneCallbackAsync();
972
+ }
973
+ }
974
+ }
975
+
976
+ function cancelChildAnimations(element) {
977
+ var node = extractElementNode(element);
978
+ if (node) {
979
+ var nodes = angular.isFunction(node.getElementsByClassName) ?
980
+ node.getElementsByClassName(NG_ANIMATE_CLASS_NAME) :
981
+ node.querySelectorAll('.' + NG_ANIMATE_CLASS_NAME);
982
+ forEach(nodes, function(element) {
983
+ element = angular.element(element);
984
+ var data = element.data(NG_ANIMATE_STATE);
985
+ if(data && data.active) {
986
+ forEach(data.active, function(runner) {
987
+ runner.cancel();
988
+ });
989
+ }
990
+ });
991
+ }
992
+ }
993
+
994
+ function cleanup(element, className) {
995
+ if(isMatchingElement(element, $rootElement)) {
996
+ if(!rootAnimateState.disabled) {
997
+ rootAnimateState.running = false;
998
+ rootAnimateState.structural = false;
999
+ }
1000
+ } else if(className) {
1001
+ var data = element.data(NG_ANIMATE_STATE) || {};
1002
+
1003
+ var removeAnimations = className === true;
1004
+ if(!removeAnimations && data.active && data.active[className]) {
1005
+ data.totalActive--;
1006
+ delete data.active[className];
1007
+ }
1008
+
1009
+ if(removeAnimations || !data.totalActive) {
1010
+ element.removeClass(NG_ANIMATE_CLASS_NAME);
1011
+ element.removeData(NG_ANIMATE_STATE);
1012
+ }
1013
+ }
1014
+ }
1015
+
1016
+ function animationsDisabled(element, parentElement) {
1017
+ if (rootAnimateState.disabled) return true;
1018
+
1019
+ if(isMatchingElement(element, $rootElement)) {
1020
+ return rootAnimateState.disabled || rootAnimateState.running;
1021
+ }
1022
+
1023
+ do {
1024
+ //the element did not reach the root element which means that it
1025
+ //is not apart of the DOM. Therefore there is no reason to do
1026
+ //any animations on it
1027
+ if(parentElement.length === 0) break;
1028
+
1029
+ var isRoot = isMatchingElement(parentElement, $rootElement);
1030
+ var state = isRoot ? rootAnimateState : parentElement.data(NG_ANIMATE_STATE);
1031
+ var result = state && (!!state.disabled || state.running || state.totalActive > 0);
1032
+ if(isRoot || result) {
1033
+ return result;
1034
+ }
1035
+
1036
+ if(isRoot) return true;
1037
+ }
1038
+ while(parentElement = parentElement.parent());
1039
+
1040
+ return true;
1041
+ }
1042
+ }]);
1043
+
1044
+ $animateProvider.register('', ['$window', '$sniffer', '$timeout', '$$animateReflow',
1045
+ function($window, $sniffer, $timeout, $$animateReflow) {
1046
+ // Detect proper transitionend/animationend event names.
1047
+ var CSS_PREFIX = '', TRANSITION_PROP, TRANSITIONEND_EVENT, ANIMATION_PROP, ANIMATIONEND_EVENT;
1048
+
1049
+ // If unprefixed events are not supported but webkit-prefixed are, use the latter.
1050
+ // Otherwise, just use W3C names, browsers not supporting them at all will just ignore them.
1051
+ // Note: Chrome implements `window.onwebkitanimationend` and doesn't implement `window.onanimationend`
1052
+ // but at the same time dispatches the `animationend` event and not `webkitAnimationEnd`.
1053
+ // Register both events in case `window.onanimationend` is not supported because of that,
1054
+ // do the same for `transitionend` as Safari is likely to exhibit similar behavior.
1055
+ // Also, the only modern browser that uses vendor prefixes for transitions/keyframes is webkit
1056
+ // therefore there is no reason to test anymore for other vendor prefixes: http://caniuse.com/#search=transition
1057
+ if (window.ontransitionend === undefined && window.onwebkittransitionend !== undefined) {
1058
+ CSS_PREFIX = '-webkit-';
1059
+ TRANSITION_PROP = 'WebkitTransition';
1060
+ TRANSITIONEND_EVENT = 'webkitTransitionEnd transitionend';
1061
+ } else {
1062
+ TRANSITION_PROP = 'transition';
1063
+ TRANSITIONEND_EVENT = 'transitionend';
1064
+ }
1065
+
1066
+ if (window.onanimationend === undefined && window.onwebkitanimationend !== undefined) {
1067
+ CSS_PREFIX = '-webkit-';
1068
+ ANIMATION_PROP = 'WebkitAnimation';
1069
+ ANIMATIONEND_EVENT = 'webkitAnimationEnd animationend';
1070
+ } else {
1071
+ ANIMATION_PROP = 'animation';
1072
+ ANIMATIONEND_EVENT = 'animationend';
1073
+ }
1074
+
1075
+ var DURATION_KEY = 'Duration';
1076
+ var PROPERTY_KEY = 'Property';
1077
+ var DELAY_KEY = 'Delay';
1078
+ var ANIMATION_ITERATION_COUNT_KEY = 'IterationCount';
1079
+ var NG_ANIMATE_PARENT_KEY = '$$ngAnimateKey';
1080
+ var NG_ANIMATE_CSS_DATA_KEY = '$$ngAnimateCSS3Data';
1081
+ var NG_ANIMATE_BLOCK_CLASS_NAME = 'ng-animate-block-transitions';
1082
+ var ELAPSED_TIME_MAX_DECIMAL_PLACES = 3;
1083
+ var CLOSING_TIME_BUFFER = 1.5;
1084
+ var ONE_SECOND = 1000;
1085
+
1086
+ var lookupCache = {};
1087
+ var parentCounter = 0;
1088
+ var animationReflowQueue = [];
1089
+ var cancelAnimationReflow;
1090
+ function afterReflow(element, callback) {
1091
+ if(cancelAnimationReflow) {
1092
+ cancelAnimationReflow();
1093
+ }
1094
+ animationReflowQueue.push(callback);
1095
+ cancelAnimationReflow = $$animateReflow(function() {
1096
+ forEach(animationReflowQueue, function(fn) {
1097
+ fn();
1098
+ });
1099
+
1100
+ animationReflowQueue = [];
1101
+ cancelAnimationReflow = null;
1102
+ lookupCache = {};
1103
+ });
1104
+ }
1105
+
1106
+ var closingTimer = null;
1107
+ var closingTimestamp = 0;
1108
+ var animationElementQueue = [];
1109
+ function animationCloseHandler(element, totalTime) {
1110
+ var node = extractElementNode(element);
1111
+ element = angular.element(node);
1112
+
1113
+ //this item will be garbage collected by the closing
1114
+ //animation timeout
1115
+ animationElementQueue.push(element);
1116
+
1117
+ //but it may not need to cancel out the existing timeout
1118
+ //if the timestamp is less than the previous one
1119
+ var futureTimestamp = Date.now() + (totalTime * 1000);
1120
+ if(futureTimestamp <= closingTimestamp) {
1121
+ return;
1122
+ }
1123
+
1124
+ $timeout.cancel(closingTimer);
1125
+
1126
+ closingTimestamp = futureTimestamp;
1127
+ closingTimer = $timeout(function() {
1128
+ closeAllAnimations(animationElementQueue);
1129
+ animationElementQueue = [];
1130
+ }, totalTime, false);
1131
+ }
1132
+
1133
+ function closeAllAnimations(elements) {
1134
+ forEach(elements, function(element) {
1135
+ var elementData = element.data(NG_ANIMATE_CSS_DATA_KEY);
1136
+ if(elementData) {
1137
+ (elementData.closeAnimationFn || noop)();
1138
+ }
1139
+ });
1140
+ }
1141
+
1142
+ function getElementAnimationDetails(element, cacheKey) {
1143
+ var data = cacheKey ? lookupCache[cacheKey] : null;
1144
+ if(!data) {
1145
+ var transitionDuration = 0;
1146
+ var transitionDelay = 0;
1147
+ var animationDuration = 0;
1148
+ var animationDelay = 0;
1149
+ var transitionDelayStyle;
1150
+ var animationDelayStyle;
1151
+ var transitionDurationStyle;
1152
+ var transitionPropertyStyle;
1153
+
1154
+ //we want all the styles defined before and after
1155
+ forEach(element, function(element) {
1156
+ if (element.nodeType == ELEMENT_NODE) {
1157
+ var elementStyles = $window.getComputedStyle(element) || {};
1158
+
1159
+ transitionDurationStyle = elementStyles[TRANSITION_PROP + DURATION_KEY];
1160
+
1161
+ transitionDuration = Math.max(parseMaxTime(transitionDurationStyle), transitionDuration);
1162
+
1163
+ transitionPropertyStyle = elementStyles[TRANSITION_PROP + PROPERTY_KEY];
1164
+
1165
+ transitionDelayStyle = elementStyles[TRANSITION_PROP + DELAY_KEY];
1166
+
1167
+ transitionDelay = Math.max(parseMaxTime(transitionDelayStyle), transitionDelay);
1168
+
1169
+ animationDelayStyle = elementStyles[ANIMATION_PROP + DELAY_KEY];
1170
+
1171
+ animationDelay = Math.max(parseMaxTime(animationDelayStyle), animationDelay);
1172
+
1173
+ var aDuration = parseMaxTime(elementStyles[ANIMATION_PROP + DURATION_KEY]);
1174
+
1175
+ if(aDuration > 0) {
1176
+ aDuration *= parseInt(elementStyles[ANIMATION_PROP + ANIMATION_ITERATION_COUNT_KEY], 10) || 1;
1177
+ }
1178
+
1179
+ animationDuration = Math.max(aDuration, animationDuration);
1180
+ }
1181
+ });
1182
+ data = {
1183
+ total : 0,
1184
+ transitionPropertyStyle: transitionPropertyStyle,
1185
+ transitionDurationStyle: transitionDurationStyle,
1186
+ transitionDelayStyle: transitionDelayStyle,
1187
+ transitionDelay: transitionDelay,
1188
+ transitionDuration: transitionDuration,
1189
+ animationDelayStyle: animationDelayStyle,
1190
+ animationDelay: animationDelay,
1191
+ animationDuration: animationDuration
1192
+ };
1193
+ if(cacheKey) {
1194
+ lookupCache[cacheKey] = data;
1195
+ }
1196
+ }
1197
+ return data;
1198
+ }
1199
+
1200
+ function parseMaxTime(str) {
1201
+ var maxValue = 0;
1202
+ var values = angular.isString(str) ?
1203
+ str.split(/\s*,\s*/) :
1204
+ [];
1205
+ forEach(values, function(value) {
1206
+ maxValue = Math.max(parseFloat(value) || 0, maxValue);
1207
+ });
1208
+ return maxValue;
1209
+ }
1210
+
1211
+ function getCacheKey(element) {
1212
+ var parentElement = element.parent();
1213
+ var parentID = parentElement.data(NG_ANIMATE_PARENT_KEY);
1214
+ if(!parentID) {
1215
+ parentElement.data(NG_ANIMATE_PARENT_KEY, ++parentCounter);
1216
+ parentID = parentCounter;
1217
+ }
1218
+ return parentID + '-' + extractElementNode(element).className;
1219
+ }
1220
+
1221
+ function animateSetup(animationEvent, element, className, calculationDecorator) {
1222
+ var cacheKey = getCacheKey(element);
1223
+ var eventCacheKey = cacheKey + ' ' + className;
1224
+ var itemIndex = lookupCache[eventCacheKey] ? ++lookupCache[eventCacheKey].total : 0;
1225
+
1226
+ var stagger = {};
1227
+ if(itemIndex > 0) {
1228
+ var staggerClassName = className + '-stagger';
1229
+ var staggerCacheKey = cacheKey + ' ' + staggerClassName;
1230
+ var applyClasses = !lookupCache[staggerCacheKey];
1231
+
1232
+ applyClasses && element.addClass(staggerClassName);
1233
+
1234
+ stagger = getElementAnimationDetails(element, staggerCacheKey);
1235
+
1236
+ applyClasses && element.removeClass(staggerClassName);
1237
+ }
1238
+
1239
+ /* the animation itself may need to add/remove special CSS classes
1240
+ * before calculating the anmation styles */
1241
+ calculationDecorator = calculationDecorator ||
1242
+ function(fn) { return fn(); };
1243
+
1244
+ element.addClass(className);
1245
+
1246
+ var formerData = element.data(NG_ANIMATE_CSS_DATA_KEY) || {};
1247
+
1248
+ var timings = calculationDecorator(function() {
1249
+ return getElementAnimationDetails(element, eventCacheKey);
1250
+ });
1251
+
1252
+ var transitionDuration = timings.transitionDuration;
1253
+ var animationDuration = timings.animationDuration;
1254
+ if(transitionDuration === 0 && animationDuration === 0) {
1255
+ element.removeClass(className);
1256
+ return false;
1257
+ }
1258
+
1259
+ element.data(NG_ANIMATE_CSS_DATA_KEY, {
1260
+ running : formerData.running || 0,
1261
+ itemIndex : itemIndex,
1262
+ stagger : stagger,
1263
+ timings : timings,
1264
+ closeAnimationFn : noop
1265
+ });
1266
+
1267
+ //temporarily disable the transition so that the enter styles
1268
+ //don't animate twice (this is here to avoid a bug in Chrome/FF).
1269
+ var isCurrentlyAnimating = formerData.running > 0 || animationEvent == 'setClass';
1270
+ if(transitionDuration > 0) {
1271
+ blockTransitions(element, className, isCurrentlyAnimating);
1272
+ }
1273
+
1274
+ //staggering keyframe animations work by adjusting the `animation-delay` CSS property
1275
+ //on the given element, however, the delay value can only calculated after the reflow
1276
+ //since by that time $animate knows how many elements are being animated. Therefore,
1277
+ //until the reflow occurs the element needs to be blocked (where the keyframe animation
1278
+ //is set to `none 0s`). This blocking mechanism should only be set for when a stagger
1279
+ //animation is detected and when the element item index is greater than 0.
1280
+ if(animationDuration > 0 && stagger.animationDelay > 0 && stagger.animationDuration === 0) {
1281
+ blockKeyframeAnimations(element);
1282
+ }
1283
+
1284
+ return true;
1285
+ }
1286
+
1287
+ function isStructuralAnimation(className) {
1288
+ return className == 'ng-enter' || className == 'ng-move' || className == 'ng-leave';
1289
+ }
1290
+
1291
+ function blockTransitions(element, className, isAnimating) {
1292
+ if(isStructuralAnimation(className) || !isAnimating) {
1293
+ extractElementNode(element).style[TRANSITION_PROP + PROPERTY_KEY] = 'none';
1294
+ } else {
1295
+ element.addClass(NG_ANIMATE_BLOCK_CLASS_NAME);
1296
+ }
1297
+ }
1298
+
1299
+ function blockKeyframeAnimations(element) {
1300
+ extractElementNode(element).style[ANIMATION_PROP] = 'none 0s';
1301
+ }
1302
+
1303
+ function unblockTransitions(element, className) {
1304
+ var prop = TRANSITION_PROP + PROPERTY_KEY;
1305
+ var node = extractElementNode(element);
1306
+ if(node.style[prop] && node.style[prop].length > 0) {
1307
+ node.style[prop] = '';
1308
+ }
1309
+ element.removeClass(NG_ANIMATE_BLOCK_CLASS_NAME);
1310
+ }
1311
+
1312
+ function unblockKeyframeAnimations(element) {
1313
+ var prop = ANIMATION_PROP;
1314
+ var node = extractElementNode(element);
1315
+ if(node.style[prop] && node.style[prop].length > 0) {
1316
+ node.style[prop] = '';
1317
+ }
1318
+ }
1319
+
1320
+ function animateRun(animationEvent, element, className, activeAnimationComplete) {
1321
+ var node = extractElementNode(element);
1322
+ var elementData = element.data(NG_ANIMATE_CSS_DATA_KEY);
1323
+ if(node.className.indexOf(className) == -1 || !elementData) {
1324
+ activeAnimationComplete();
1325
+ return;
1326
+ }
1327
+
1328
+ var activeClassName = '';
1329
+ forEach(className.split(' '), function(klass, i) {
1330
+ activeClassName += (i > 0 ? ' ' : '') + klass + '-active';
1331
+ });
1332
+
1333
+ var stagger = elementData.stagger;
1334
+ var timings = elementData.timings;
1335
+ var itemIndex = elementData.itemIndex;
1336
+ var maxDuration = Math.max(timings.transitionDuration, timings.animationDuration);
1337
+ var maxDelay = Math.max(timings.transitionDelay, timings.animationDelay);
1338
+ var maxDelayTime = maxDelay * ONE_SECOND;
1339
+
1340
+ var startTime = Date.now();
1341
+ var css3AnimationEvents = ANIMATIONEND_EVENT + ' ' + TRANSITIONEND_EVENT;
1342
+
1343
+ var style = '', appliedStyles = [];
1344
+ if(timings.transitionDuration > 0) {
1345
+ var propertyStyle = timings.transitionPropertyStyle;
1346
+ if(propertyStyle.indexOf('all') == -1) {
1347
+ style += CSS_PREFIX + 'transition-property: ' + propertyStyle + ';';
1348
+ style += CSS_PREFIX + 'transition-duration: ' + timings.transitionDurationStyle + ';';
1349
+ appliedStyles.push(CSS_PREFIX + 'transition-property');
1350
+ appliedStyles.push(CSS_PREFIX + 'transition-duration');
1351
+ }
1352
+ }
1353
+
1354
+ if(itemIndex > 0) {
1355
+ if(stagger.transitionDelay > 0 && stagger.transitionDuration === 0) {
1356
+ var delayStyle = timings.transitionDelayStyle;
1357
+ style += CSS_PREFIX + 'transition-delay: ' +
1358
+ prepareStaggerDelay(delayStyle, stagger.transitionDelay, itemIndex) + '; ';
1359
+ appliedStyles.push(CSS_PREFIX + 'transition-delay');
1360
+ }
1361
+
1362
+ if(stagger.animationDelay > 0 && stagger.animationDuration === 0) {
1363
+ style += CSS_PREFIX + 'animation-delay: ' +
1364
+ prepareStaggerDelay(timings.animationDelayStyle, stagger.animationDelay, itemIndex) + '; ';
1365
+ appliedStyles.push(CSS_PREFIX + 'animation-delay');
1366
+ }
1367
+ }
1368
+
1369
+ if(appliedStyles.length > 0) {
1370
+ //the element being animated may sometimes contain comment nodes in
1371
+ //the jqLite object, so we're safe to use a single variable to house
1372
+ //the styles since there is always only one element being animated
1373
+ var oldStyle = node.getAttribute('style') || '';
1374
+ node.setAttribute('style', oldStyle + ' ' + style);
1375
+ }
1376
+
1377
+ element.on(css3AnimationEvents, onAnimationProgress);
1378
+ element.addClass(activeClassName);
1379
+ elementData.closeAnimationFn = function() {
1380
+ onEnd();
1381
+ activeAnimationComplete();
1382
+ };
1383
+
1384
+ var staggerTime = itemIndex * (Math.max(stagger.animationDelay, stagger.transitionDelay) || 0);
1385
+ var animationTime = (maxDelay + maxDuration) * CLOSING_TIME_BUFFER;
1386
+ var totalTime = (staggerTime + animationTime) * ONE_SECOND;
1387
+
1388
+ elementData.running++;
1389
+ animationCloseHandler(element, totalTime);
1390
+ return onEnd;
1391
+
1392
+ // This will automatically be called by $animate so
1393
+ // there is no need to attach this internally to the
1394
+ // timeout done method.
1395
+ function onEnd(cancelled) {
1396
+ element.off(css3AnimationEvents, onAnimationProgress);
1397
+ element.removeClass(activeClassName);
1398
+ animateClose(element, className);
1399
+ var node = extractElementNode(element);
1400
+ for (var i in appliedStyles) {
1401
+ node.style.removeProperty(appliedStyles[i]);
1402
+ }
1403
+ }
1404
+
1405
+ function onAnimationProgress(event) {
1406
+ event.stopPropagation();
1407
+ var ev = event.originalEvent || event;
1408
+ var timeStamp = ev.$manualTimeStamp || ev.timeStamp || Date.now();
1409
+
1410
+ /* Firefox (or possibly just Gecko) likes to not round values up
1411
+ * when a ms measurement is used for the animation */
1412
+ var elapsedTime = parseFloat(ev.elapsedTime.toFixed(ELAPSED_TIME_MAX_DECIMAL_PLACES));
1413
+
1414
+ /* $manualTimeStamp is a mocked timeStamp value which is set
1415
+ * within browserTrigger(). This is only here so that tests can
1416
+ * mock animations properly. Real events fallback to event.timeStamp,
1417
+ * or, if they don't, then a timeStamp is automatically created for them.
1418
+ * We're checking to see if the timeStamp surpasses the expected delay,
1419
+ * but we're using elapsedTime instead of the timeStamp on the 2nd
1420
+ * pre-condition since animations sometimes close off early */
1421
+ if(Math.max(timeStamp - startTime, 0) >= maxDelayTime && elapsedTime >= maxDuration) {
1422
+ activeAnimationComplete();
1423
+ }
1424
+ }
1425
+ }
1426
+
1427
+ function prepareStaggerDelay(delayStyle, staggerDelay, index) {
1428
+ var style = '';
1429
+ forEach(delayStyle.split(','), function(val, i) {
1430
+ style += (i > 0 ? ',' : '') +
1431
+ (index * staggerDelay + parseInt(val, 10)) + 's';
1432
+ });
1433
+ return style;
1434
+ }
1435
+
1436
+ function animateBefore(animationEvent, element, className, calculationDecorator) {
1437
+ if(animateSetup(animationEvent, element, className, calculationDecorator)) {
1438
+ return function(cancelled) {
1439
+ cancelled && animateClose(element, className);
1440
+ };
1441
+ }
1442
+ }
1443
+
1444
+ function animateAfter(animationEvent, element, className, afterAnimationComplete) {
1445
+ if(element.data(NG_ANIMATE_CSS_DATA_KEY)) {
1446
+ return animateRun(animationEvent, element, className, afterAnimationComplete);
1447
+ } else {
1448
+ animateClose(element, className);
1449
+ afterAnimationComplete();
1450
+ }
1451
+ }
1452
+
1453
+ function animate(animationEvent, element, className, animationComplete) {
1454
+ //If the animateSetup function doesn't bother returning a
1455
+ //cancellation function then it means that there is no animation
1456
+ //to perform at all
1457
+ var preReflowCancellation = animateBefore(animationEvent, element, className);
1458
+ if(!preReflowCancellation) {
1459
+ animationComplete();
1460
+ return;
1461
+ }
1462
+
1463
+ //There are two cancellation functions: one is before the first
1464
+ //reflow animation and the second is during the active state
1465
+ //animation. The first function will take care of removing the
1466
+ //data from the element which will not make the 2nd animation
1467
+ //happen in the first place
1468
+ var cancel = preReflowCancellation;
1469
+ afterReflow(element, function() {
1470
+ unblockTransitions(element, className);
1471
+ unblockKeyframeAnimations(element);
1472
+ //once the reflow is complete then we point cancel to
1473
+ //the new cancellation function which will remove all of the
1474
+ //animation properties from the active animation
1475
+ cancel = animateAfter(animationEvent, element, className, animationComplete);
1476
+ });
1477
+
1478
+ return function(cancelled) {
1479
+ (cancel || noop)(cancelled);
1480
+ };
1481
+ }
1482
+
1483
+ function animateClose(element, className) {
1484
+ element.removeClass(className);
1485
+ var data = element.data(NG_ANIMATE_CSS_DATA_KEY);
1486
+ if(data) {
1487
+ if(data.running) {
1488
+ data.running--;
1489
+ }
1490
+ if(!data.running || data.running === 0) {
1491
+ element.removeData(NG_ANIMATE_CSS_DATA_KEY);
1492
+ }
1493
+ }
1494
+ }
1495
+
1496
+ return {
1497
+ enter : function(element, animationCompleted) {
1498
+ return animate('enter', element, 'ng-enter', animationCompleted);
1499
+ },
1500
+
1501
+ leave : function(element, animationCompleted) {
1502
+ return animate('leave', element, 'ng-leave', animationCompleted);
1503
+ },
1504
+
1505
+ move : function(element, animationCompleted) {
1506
+ return animate('move', element, 'ng-move', animationCompleted);
1507
+ },
1508
+
1509
+ beforeSetClass : function(element, add, remove, animationCompleted) {
1510
+ var className = suffixClasses(remove, '-remove') + ' ' +
1511
+ suffixClasses(add, '-add');
1512
+ var cancellationMethod = animateBefore('setClass', element, className, function(fn) {
1513
+ /* when classes are removed from an element then the transition style
1514
+ * that is applied is the transition defined on the element without the
1515
+ * CSS class being there. This is how CSS3 functions outside of ngAnimate.
1516
+ * http://plnkr.co/edit/j8OzgTNxHTb4n3zLyjGW?p=preview */
1517
+ var klass = element.attr('class');
1518
+ element.removeClass(remove);
1519
+ element.addClass(add);
1520
+ var timings = fn();
1521
+ element.attr('class', klass);
1522
+ return timings;
1523
+ });
1524
+
1525
+ if(cancellationMethod) {
1526
+ afterReflow(element, function() {
1527
+ unblockTransitions(element, className);
1528
+ unblockKeyframeAnimations(element);
1529
+ animationCompleted();
1530
+ });
1531
+ return cancellationMethod;
1532
+ }
1533
+ animationCompleted();
1534
+ },
1535
+
1536
+ beforeAddClass : function(element, className, animationCompleted) {
1537
+ var cancellationMethod = animateBefore('addClass', element, suffixClasses(className, '-add'), function(fn) {
1538
+
1539
+ /* when a CSS class is added to an element then the transition style that
1540
+ * is applied is the transition defined on the element when the CSS class
1541
+ * is added at the time of the animation. This is how CSS3 functions
1542
+ * outside of ngAnimate. */
1543
+ element.addClass(className);
1544
+ var timings = fn();
1545
+ element.removeClass(className);
1546
+ return timings;
1547
+ });
1548
+
1549
+ if(cancellationMethod) {
1550
+ afterReflow(element, function() {
1551
+ unblockTransitions(element, className);
1552
+ unblockKeyframeAnimations(element);
1553
+ animationCompleted();
1554
+ });
1555
+ return cancellationMethod;
1556
+ }
1557
+ animationCompleted();
1558
+ },
1559
+
1560
+ setClass : function(element, add, remove, animationCompleted) {
1561
+ remove = suffixClasses(remove, '-remove');
1562
+ add = suffixClasses(add, '-add');
1563
+ var className = remove + ' ' + add;
1564
+ return animateAfter('setClass', element, className, animationCompleted);
1565
+ },
1566
+
1567
+ addClass : function(element, className, animationCompleted) {
1568
+ return animateAfter('addClass', element, suffixClasses(className, '-add'), animationCompleted);
1569
+ },
1570
+
1571
+ beforeRemoveClass : function(element, className, animationCompleted) {
1572
+ var cancellationMethod = animateBefore('removeClass', element, suffixClasses(className, '-remove'), function(fn) {
1573
+ /* when classes are removed from an element then the transition style
1574
+ * that is applied is the transition defined on the element without the
1575
+ * CSS class being there. This is how CSS3 functions outside of ngAnimate.
1576
+ * http://plnkr.co/edit/j8OzgTNxHTb4n3zLyjGW?p=preview */
1577
+ var klass = element.attr('class');
1578
+ element.removeClass(className);
1579
+ var timings = fn();
1580
+ element.attr('class', klass);
1581
+ return timings;
1582
+ });
1583
+
1584
+ if(cancellationMethod) {
1585
+ afterReflow(element, function() {
1586
+ unblockTransitions(element, className);
1587
+ unblockKeyframeAnimations(element);
1588
+ animationCompleted();
1589
+ });
1590
+ return cancellationMethod;
1591
+ }
1592
+ animationCompleted();
1593
+ },
1594
+
1595
+ removeClass : function(element, className, animationCompleted) {
1596
+ return animateAfter('removeClass', element, suffixClasses(className, '-remove'), animationCompleted);
1597
+ }
1598
+ };
1599
+
1600
+ function suffixClasses(classes, suffix) {
1601
+ var className = '';
1602
+ classes = angular.isArray(classes) ? classes : classes.split(/\s+/);
1603
+ forEach(classes, function(klass, i) {
1604
+ if(klass && klass.length > 0) {
1605
+ className += (i > 0 ? ' ' : '') + klass + suffix;
1606
+ }
1607
+ });
1608
+ return className;
1609
+ }
1610
+ }]);
1611
+ }]);
1612
+
1613
+
1614
+ })(window, window.angular);