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