@angular-wave/angular.ts 0.0.14 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/angular-ts.esm.js +1 -1
  2. package/dist/angular-ts.umd.js +1 -1
  3. package/package.json +1 -1
  4. package/rollup.config.js +6 -2
  5. package/src/animations/animate-css.js +13 -218
  6. package/src/animations/animate.css.md +263 -0
  7. package/src/animations/animate.md +933 -0
  8. package/src/animations/module.js +0 -750
  9. package/src/animations/shared.js +0 -11
  10. package/src/core/compile.js +1 -1
  11. package/src/exts/messages.md +30 -30
  12. package/src/router/adapter/directives/stateDirectives.js +3 -4
  13. package/src/router/adapter/directives/viewDirective.js +3 -4
  14. package/src/router/adapter/services.js +4 -2
  15. package/src/router/adapter/statebuilders/onEnterExitRetain.js +1 -2
  16. package/src/router/adapter/statebuilders/views.js +4 -5
  17. package/src/router/core/common/common.js +10 -22
  18. package/src/router/core/common/safeConsole.js +1 -2
  19. package/src/router/core/hooks/resolve.js +3 -4
  20. package/src/router/core/hooks/views.js +3 -2
  21. package/src/router/core/params/param.js +5 -5
  22. package/src/router/core/params/paramType.js +3 -3
  23. package/src/router/core/params/paramTypes.js +6 -7
  24. package/src/router/core/params/stateParams.js +3 -3
  25. package/src/router/core/path/pathNode.js +2 -2
  26. package/src/router/core/path/pathUtils.js +4 -5
  27. package/src/router/core/resolve/resolvable.js +2 -2
  28. package/src/router/core/state/stateBuilder.js +1 -2
  29. package/src/router/core/state/stateService.js +2 -3
  30. package/src/router/core/state/targetState.js +8 -5
  31. package/src/router/core/transition/hookBuilder.js +2 -2
  32. package/src/router/core/transition/hookRegistry.js +2 -2
  33. package/src/router/core/transition/rejectFactory.js +2 -3
  34. package/src/router/core/transition/transition.js +5 -3
  35. package/src/router/core/url/urlMatcherFactory.js +2 -8
  36. package/src/router/core/url/urlRule.js +7 -4
  37. package/src/router/core/url/urlService.js +2 -2
  38. package/src/router/router.js +11 -10
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@angular-wave/angular.ts",
3
3
  "license": "MIT",
4
- "version": "0.0.14",
4
+ "version": "0.0.16",
5
5
  "type": "module",
6
6
  "main": "dist/angular-ts.esm.js",
7
7
  "browser": "dist/angular-ts.umd.js",
package/rollup.config.js CHANGED
@@ -3,6 +3,10 @@ import commonjs from '@rollup/plugin-commonjs';
3
3
  import pkg from './package.json' assert { type: 'json' };
4
4
  import terser from '@rollup/plugin-terser';
5
5
 
6
+ const terserConfig = terser({
7
+ mangle: true
8
+ })
9
+
6
10
  export default [
7
11
  // browser-friendly UMD build
8
12
  {
@@ -12,7 +16,7 @@ export default [
12
16
  file: pkg.browser,
13
17
  format: 'umd',
14
18
  },
15
- plugins: [resolve(), commonjs(), terser()],
19
+ plugins: [resolve(), commonjs(), terserConfig],
16
20
  },
17
21
 
18
22
  // ES module (for bundlers) build.
@@ -25,6 +29,6 @@ export default [
25
29
  input: 'src/index.js',
26
30
  external: ['ms'],
27
31
  output: { file: pkg.main, format: 'es' },
28
- plugins: [terser()],
32
+ plugins: [terserConfig],
29
33
  },
30
34
  ];
@@ -32,220 +32,6 @@ import {
32
32
 
33
33
  const ANIMATE_TIMER_KEY = "$$animateCss";
34
34
 
35
- /**
36
- * @ngdoc service
37
- * @name $animateCss
38
- * @kind object
39
- *
40
- * @description
41
- * The `$animateCss` service is a useful utility to trigger customized CSS-based transitions/keyframes
42
- * from a JavaScript-based animation or directly from a directive. The purpose of `$animateCss` is NOT
43
- * to side-step how `$animate` and ngAnimate work, but the goal is to allow pre-existing animations or
44
- * directives to create more complex animations that can be purely driven using CSS code.
45
- *
46
- * Note that only browsers that support CSS transitions and/or keyframe animations are capable of
47
- * rendering animations triggered via `$animateCss` (bad news for IE9 and lower).
48
- *
49
- * ## General Use
50
- * Once again, `$animateCss` is designed to be used inside of a registered JavaScript animation that
51
- * is powered by ngAnimate. It is possible to use `$animateCss` directly inside of a directive, however,
52
- * any automatic control over cancelling animations and/or preventing animations from being run on
53
- * child elements will not be handled by AngularJS. For this to work as expected, please use `$animate` to
54
- * trigger the animation and then setup a JavaScript animation that injects `$animateCss` to trigger
55
- * the CSS animation.
56
- *
57
- * The example below shows how we can create a folding animation on an element using `ng-if`:
58
- *
59
- * ```html
60
- * <!-- notice the `fold-animation` CSS class -->
61
- * <div ng-if="onOff" class="fold-animation">
62
- * This element will go BOOM
63
- * </div>
64
- * <button ng-click="onOff=true">Fold In</button>
65
- * ```
66
- *
67
- * Now we create the **JavaScript animation** that will trigger the CSS transition:
68
- *
69
- * ```js
70
- * ngModule.animation('.fold-animation', ['$animateCss', function($animateCss) {
71
- * return {
72
- * enter: function(element, doneFn) {
73
- * let height = element[0].offsetHeight;
74
- * return $animateCss(element, {
75
- * from: { height:'0px' },
76
- * to: { height:height + 'px' },
77
- * duration: 1 // one second
78
- * });
79
- * }
80
- * }
81
- * }]);
82
- * ```
83
- *
84
- * ## More Advanced Uses
85
- *
86
- * `$animateCss` is the underlying code that ngAnimate uses to power **CSS-based animations** behind the scenes. Therefore CSS hooks
87
- * like `.ng-EVENT`, `.ng-EVENT-active`, `.ng-EVENT-stagger` are all features that can be triggered using `$animateCss` via JavaScript code.
88
- *
89
- * This also means that just about any combination of adding classes, removing classes, setting styles, dynamically setting a keyframe animation,
90
- * applying a hardcoded duration or delay value, changing the animation easing or applying a stagger animation are all options that work with
91
- * `$animateCss`. The service itself is smart enough to figure out the combination of options and examine the element styling properties in order
92
- * to provide a working animation that will run in CSS.
93
- *
94
- * The example below showcases a more advanced version of the `.fold-animation` from the example above:
95
- *
96
- * ```js
97
- * ngModule.animation('.fold-animation', ['$animateCss', function($animateCss) {
98
- * return {
99
- * enter: function(element, doneFn) {
100
- * let height = element[0].offsetHeight;
101
- * return $animateCss(element, {
102
- * addClass: 'red large-text pulse-twice',
103
- * easing: 'ease-out',
104
- * from: { height:'0px' },
105
- * to: { height:height + 'px' },
106
- * duration: 1 // one second
107
- * });
108
- * }
109
- * }
110
- * }]);
111
- * ```
112
- *
113
- * Since we're adding/removing CSS classes then the CSS transition will also pick those up:
114
- *
115
- * ```css
116
- * /&#42; since a hardcoded duration value of 1 was provided in the JavaScript animation code,
117
- * the CSS classes below will be transitioned despite them being defined as regular CSS classes &#42;/
118
- * .red { background:red; }
119
- * .large-text { font-size:20px; }
120
- *
121
- * /&#42; we can also use a keyframe animation and $animateCss will make it work alongside the transition &#42;/
122
- * .pulse-twice {
123
- * animation: 0.5s pulse linear 2;
124
- * -webkit-animation: 0.5s pulse linear 2;
125
- * }
126
- *
127
- * @keyframes pulse {
128
- * from { transform: scale(0.5); }
129
- * to { transform: scale(1.5); }
130
- * }
131
- *
132
- * @-webkit-keyframes pulse {
133
- * from { -webkit-transform: scale(0.5); }
134
- * to { -webkit-transform: scale(1.5); }
135
- * }
136
- * ```
137
- *
138
- * Given this complex combination of CSS classes, styles and options, `$animateCss` will figure everything out and make the animation happen.
139
- *
140
- * ## How the Options are handled
141
- *
142
- * `$animateCss` is very versatile and intelligent when it comes to figuring out what configurations to apply to the element to ensure the animation
143
- * works with the options provided. Say for example we were adding a class that contained a keyframe value and we wanted to also animate some inline
144
- * styles using the `from` and `to` properties.
145
- *
146
- * ```js
147
- * let animator = $animateCss(element, {
148
- * from: { background:'red' },
149
- * to: { background:'blue' }
150
- * });
151
- * animator.start();
152
- * ```
153
- *
154
- * ```css
155
- * .rotating-animation {
156
- * animation:0.5s rotate linear;
157
- * -webkit-animation:0.5s rotate linear;
158
- * }
159
- *
160
- * @keyframes rotate {
161
- * from { transform: rotate(0deg); }
162
- * to { transform: rotate(360deg); }
163
- * }
164
- *
165
- * @-webkit-keyframes rotate {
166
- * from { -webkit-transform: rotate(0deg); }
167
- * to { -webkit-transform: rotate(360deg); }
168
- * }
169
- * ```
170
- *
171
- * The missing pieces here are that we do not have a transition set (within the CSS code nor within the `$animateCss` options) and the duration of the animation is
172
- * going to be detected from what the keyframe styles on the CSS class are. In this event, `$animateCss` will automatically create an inline transition
173
- * style matching the duration detected from the keyframe style (which is present in the CSS class that is being added) and then prepare both the transition
174
- * and keyframe animations to run in parallel on the element. Then when the animation is underway the provided `from` and `to` CSS styles will be applied
175
- * and spread across the transition and keyframe animation.
176
- *
177
- * ## What is returned
178
- *
179
- * `$animateCss` works in two stages: a preparation phase and an animation phase. Therefore when `$animateCss` is first called it will NOT actually
180
- * start the animation. All that is going on here is that the element is being prepared for the animation (which means that the generated CSS classes are
181
- * added and removed on the element). Once `$animateCss` is called it will return an object with the following properties:
182
- *
183
- * ```js
184
- * let animator = $animateCss(element, { ... });
185
- * ```
186
- *
187
- * Now what do the contents of our `animator` variable look like:
188
- *
189
- * ```js
190
- * {
191
- * // starts the animation
192
- * start: Function,
193
- *
194
- * // ends (aborts) the animation
195
- * end: Function
196
- * }
197
- * ```
198
- *
199
- * To actually start the animation we need to run `animation.start()` which will then return a promise that we can hook into to detect when the animation ends.
200
- * If we choose not to run the animation then we MUST run `animation.end()` to perform a cleanup on the element (since some CSS classes and styles may have been
201
- * applied to the element during the preparation phase). Note that all other properties such as duration, delay, transitions and keyframes are just properties
202
- * and that changing them will not reconfigure the parameters of the animation.
203
- *
204
- * ### runner.done() vs runner.then()
205
- * It is documented that `animation.start()` will return a promise object and this is true, however, there is also an additional method available on the
206
- * runner called `.done(callbackFn)`. The done method works the same as `.finally(callbackFn)`, however, it does **not trigger a digest to occur**.
207
- * Therefore, for performance reasons, it's always best to use `runner.done(callback)` instead of `runner.then()`, `runner.catch()` or `runner.finally()`
208
- * unless you really need a digest to kick off afterwards.
209
- *
210
- * Keep in mind that, to make this easier, ngAnimate has tweaked the JS animations API to recognize when a runner instance is returned from $animateCss
211
- * (so there is no need to call `runner.done(doneFn)` inside of your JavaScript animation code).
212
- * Check the {@link ngAnimate.$animateCss#usage animation code above} to see how this works.
213
- *
214
- * @param {Element} element the element that will be animated
215
- * @param {object} options the animation-related options that will be applied during the animation
216
- *
217
- * * `event` - The DOM event (e.g. enter, leave, move). When used, a generated CSS class of `ng-EVENT` and `ng-EVENT-active` will be applied
218
- * to the element during the animation. Multiple events can be provided when spaces are used as a separator. (Note that this will not perform any DOM operation.)
219
- * * `structural` - Indicates that the `ng-` prefix will be added to the event class. Setting to `false` or omitting will turn `ng-EVENT` and
220
- * `ng-EVENT-active` in `EVENT` and `EVENT-active`. Unused if `event` is omitted.
221
- * * `easing` - The CSS easing value that will be applied to the transition or keyframe animation (or both).
222
- * * `transitionStyle` - The raw CSS transition style that will be used (e.g. `1s linear all`).
223
- * * `keyframeStyle` - The raw CSS keyframe animation style that will be used (e.g. `1s my_animation linear`).
224
- * * `from` - The starting CSS styles (a key/value object) that will be applied at the start of the animation.
225
- * * `to` - The ending CSS styles (a key/value object) that will be applied across the animation via a CSS transition.
226
- * * `addClass` - A space separated list of CSS classes that will be added to the element and spread across the animation.
227
- * * `removeClass` - A space separated list of CSS classes that will be removed from the element and spread across the animation.
228
- * * `duration` - A number value representing the total duration of the transition and/or keyframe (note that a value of 1 is 1000ms). If a value of `0`
229
- * is provided then the animation will be skipped entirely.
230
- * * `delay` - A number value representing the total delay of the transition and/or keyframe (note that a value of 1 is 1000ms). If a value of `true` is
231
- * used then whatever delay value is detected from the CSS classes will be mirrored on the elements styles (e.g. by setting delay true then the style value
232
- * of the element will be `transition-delay: DETECTED_VALUE`). Using `true` is useful when you want the CSS classes and inline styles to all share the same
233
- * CSS delay value.
234
- * * `stagger` - A numeric time value representing the delay between successively animated elements
235
- * ({@link ngAnimate#css-staggering-animations Click here to learn how CSS-based staggering works in ngAnimate.})
236
- * * `staggerIndex` - The numeric index representing the stagger item (e.g. a value of 5 is equal to the sixth item in the stagger; therefore when a
237
- * `stagger` option value of `0.1` is used then there will be a stagger delay of `600ms`)
238
- * * `applyClassesEarly` - Whether or not the classes being added or removed will be used when detecting the animation. This is set by `$animate` when enter/leave/move animations are fired to ensure that the CSS classes are resolved in time. (Note that this will prevent any transitions from occurring on the classes being added and removed.)
239
- * * `cleanupStyles` - Whether or not the provided `from` and `to` styles will be removed once
240
- * the animation is closed. This is useful for when the styles are used purely for the sake of
241
- * the animation and do not have a lasting visual effect on the element (e.g. a collapse and open animation).
242
- * By default this value is set to `false`.
243
- *
244
- * @return {object} an object with start and end methods and details about the animation.
245
- *
246
- * * `start` - The method to start the animation. This will return a `Promise` when called.
247
- * * `end` - This method will cancel the animation and remove all applied CSS classes and styles.
248
- */
249
35
  const ONE_SECOND = 1000;
250
36
 
251
37
  const ELAPSED_TIME_MAX_DECIMAL_PLACES = 3;
@@ -654,7 +440,7 @@ export const $AnimateCssProvider = [
654
440
  // that if there is no transition defined then nothing will happen and this will also allow
655
441
  // other transitions to be stacked on top of each other without any chopping them out.
656
442
  if (isFirst && !options.skipBlocking) {
657
- helpers.blockTransitions(node, SAFE_FAST_FORWARD_DURATION_VALUE);
443
+ blockTransitions(node, SAFE_FAST_FORWARD_DURATION_VALUE);
658
444
  }
659
445
 
660
446
  let timings = computeTimings(
@@ -765,7 +551,7 @@ export const $AnimateCssProvider = [
765
551
  if (flags.blockTransition || flags.blockKeyframeAnimation) {
766
552
  applyBlocking(maxDuration);
767
553
  } else if (!options.skipBlocking) {
768
- helpers.blockTransitions(node, false);
554
+ blockTransitions(node, false);
769
555
  }
770
556
 
771
557
  // TODO(matsko): for 1.5 change this code to have an animator object for better debugging
@@ -823,7 +609,7 @@ export const $AnimateCssProvider = [
823
609
  }
824
610
 
825
611
  blockKeyframeAnimations(node, false);
826
- helpers.blockTransitions(node, false);
612
+ blockTransitions(node, false);
827
613
 
828
614
  forEach(temporaryStyles, (entry) => {
829
615
  // There is only one way to remove inline style properties entirely from elements.
@@ -874,7 +660,7 @@ export const $AnimateCssProvider = [
874
660
 
875
661
  function applyBlocking(duration) {
876
662
  if (flags.blockTransition) {
877
- helpers.blockTransitions(node, duration);
663
+ blockTransitions(node, duration);
878
664
  }
879
665
 
880
666
  if (flags.blockKeyframeAnimation) {
@@ -1136,3 +922,12 @@ export const $AnimateCssProvider = [
1136
922
  ];
1137
923
  },
1138
924
  ];
925
+
926
+ function blockTransitions(node, duration) {
927
+ // we use a negative delay value since it performs blocking
928
+ // yet it doesn't kill any existing transitions running on the
929
+ // same element which makes this safe for class-based animations
930
+ const value = duration ? `-${duration}s` : "";
931
+ applyInlineStyle(node, [TRANSITION_DELAY_PROP, value]);
932
+ return [TRANSITION_DELAY_PROP, value];
933
+ }
@@ -0,0 +1,263 @@
1
+ /\*\*
2
+
3
+ - @ngdoc service
4
+ - @name $animateCss
5
+ - @kind object
6
+ -
7
+ - @description
8
+ - The `$animateCss` service is a useful utility to trigger customized CSS-based transitions/keyframes
9
+ - from a JavaScript-based animation or directly from a directive. The purpose of `$animateCss` is NOT
10
+ - to side-step how `$animate` and ngAnimate work, but the goal is to allow pre-existing animations or
11
+ - directives to create more complex animations that can be purely driven using CSS code.
12
+ -
13
+ - Note that only browsers that support CSS transitions and/or keyframe animations are capable of
14
+ - rendering animations triggered via `$animateCss` (bad news for IE9 and lower).
15
+ -
16
+ - ## General Use
17
+ - Once again, `$animateCss` is designed to be used inside of a registered JavaScript animation that
18
+ - is powered by ngAnimate. It is possible to use `$animateCss` directly inside of a directive, however,
19
+ - any automatic control over cancelling animations and/or preventing animations from being run on
20
+ - child elements will not be handled by AngularJS. For this to work as expected, please use `$animate` to
21
+ - trigger the animation and then setup a JavaScript animation that injects `$animateCss` to trigger
22
+ - the CSS animation.
23
+ -
24
+ - The example below shows how we can create a folding animation on an element using `ng-if`:
25
+ -
26
+ - ```html
27
+
28
+ ```
29
+
30
+ - <!-- notice the `fold-animation` CSS class -->
31
+ - <div ng-if="onOff" class="fold-animation">
32
+ - This element will go BOOM
33
+ - </div>
34
+ - <button ng-click="onOff=true">Fold In</button>
35
+ - ```
36
+
37
+ ```
38
+
39
+ -
40
+ - Now we create the **JavaScript animation** that will trigger the CSS transition:
41
+ -
42
+ - ```js
43
+
44
+ ```
45
+
46
+ - ngModule.animation('.fold-animation', ['$animateCss', function($animateCss) {
47
+ - return {
48
+ - enter: function(element, doneFn) {
49
+ - let height = element[0].offsetHeight;
50
+ - return $animateCss(element, {
51
+ - from: { height:'0px' },
52
+ - to: { height:height + 'px' },
53
+ - duration: 1 // one second
54
+ - });
55
+ - }
56
+ - }
57
+ - }]);
58
+ - ```
59
+
60
+ ```
61
+
62
+ -
63
+ - ## More Advanced Uses
64
+ -
65
+ - `$animateCss` is the underlying code that ngAnimate uses to power **CSS-based animations** behind the scenes. Therefore CSS hooks
66
+ - like `.ng-EVENT`, `.ng-EVENT-active`, `.ng-EVENT-stagger` are all features that can be triggered using `$animateCss` via JavaScript code.
67
+ -
68
+ - This also means that just about any combination of adding classes, removing classes, setting styles, dynamically setting a keyframe animation,
69
+ - applying a hardcoded duration or delay value, changing the animation easing or applying a stagger animation are all options that work with
70
+ - `$animateCss`. The service itself is smart enough to figure out the combination of options and examine the element styling properties in order
71
+ - to provide a working animation that will run in CSS.
72
+ -
73
+ - The example below showcases a more advanced version of the `.fold-animation` from the example above:
74
+ -
75
+ - ```js
76
+
77
+ ```
78
+
79
+ - ngModule.animation('.fold-animation', ['$animateCss', function($animateCss) {
80
+ - return {
81
+ - enter: function(element, doneFn) {
82
+ - let height = element[0].offsetHeight;
83
+ - return $animateCss(element, {
84
+ - addClass: 'red large-text pulse-twice',
85
+ - easing: 'ease-out',
86
+ - from: { height:'0px' },
87
+ - to: { height:height + 'px' },
88
+ - duration: 1 // one second
89
+ - });
90
+ - }
91
+ - }
92
+ - }]);
93
+ - ```
94
+
95
+ ```
96
+
97
+ -
98
+ - Since we're adding/removing CSS classes then the CSS transition will also pick those up:
99
+ -
100
+ - ```css
101
+
102
+ ```
103
+
104
+ - /\* since a hardcoded duration value of 1 was provided in the JavaScript animation code,
105
+ - the CSS classes below will be transitioned despite them being defined as regular CSS classes \*/
106
+ - .red { background:red; }
107
+ - .large-text { font-size:20px; }
108
+ -
109
+ - /\* we can also use a keyframe animation and $animateCss will make it work alongside the transition \*/
110
+ - .pulse-twice {
111
+ - animation: 0.5s pulse linear 2;
112
+ - -webkit-animation: 0.5s pulse linear 2;
113
+ - }
114
+ -
115
+ - @keyframes pulse {
116
+ - from { transform: scale(0.5); }
117
+ - to { transform: scale(1.5); }
118
+ - }
119
+ -
120
+ - @-webkit-keyframes pulse {
121
+ - from { -webkit-transform: scale(0.5); }
122
+ - to { -webkit-transform: scale(1.5); }
123
+ - }
124
+ - ```
125
+
126
+ ```
127
+
128
+ -
129
+ - Given this complex combination of CSS classes, styles and options, `$animateCss` will figure everything out and make the animation happen.
130
+ -
131
+ - ## How the Options are handled
132
+ -
133
+ - `$animateCss` is very versatile and intelligent when it comes to figuring out what configurations to apply to the element to ensure the animation
134
+ - works with the options provided. Say for example we were adding a class that contained a keyframe value and we wanted to also animate some inline
135
+ - styles using the `from` and `to` properties.
136
+ -
137
+ - ```js
138
+
139
+ ```
140
+
141
+ - let animator = $animateCss(element, {
142
+ - from: { background:'red' },
143
+ - to: { background:'blue' }
144
+ - });
145
+ - animator.start();
146
+ - ```
147
+
148
+ ```
149
+
150
+ -
151
+ - ```css
152
+
153
+ ```
154
+
155
+ - .rotating-animation {
156
+ - animation:0.5s rotate linear;
157
+ - -webkit-animation:0.5s rotate linear;
158
+ - }
159
+ -
160
+ - @keyframes rotate {
161
+ - from { transform: rotate(0deg); }
162
+ - to { transform: rotate(360deg); }
163
+ - }
164
+ -
165
+ - @-webkit-keyframes rotate {
166
+ - from { -webkit-transform: rotate(0deg); }
167
+ - to { -webkit-transform: rotate(360deg); }
168
+ - }
169
+ - ```
170
+
171
+ ```
172
+
173
+ -
174
+ - The missing pieces here are that we do not have a transition set (within the CSS code nor within the `$animateCss` options) and the duration of the animation is
175
+ - going to be detected from what the keyframe styles on the CSS class are. In this event, `$animateCss` will automatically create an inline transition
176
+ - style matching the duration detected from the keyframe style (which is present in the CSS class that is being added) and then prepare both the transition
177
+ - and keyframe animations to run in parallel on the element. Then when the animation is underway the provided `from` and `to` CSS styles will be applied
178
+ - and spread across the transition and keyframe animation.
179
+ -
180
+ - ## What is returned
181
+ -
182
+ - `$animateCss` works in two stages: a preparation phase and an animation phase. Therefore when `$animateCss` is first called it will NOT actually
183
+ - start the animation. All that is going on here is that the element is being prepared for the animation (which means that the generated CSS classes are
184
+ - added and removed on the element). Once `$animateCss` is called it will return an object with the following properties:
185
+ -
186
+ - ```js
187
+
188
+ ```
189
+
190
+ - let animator = $animateCss(element, { ... });
191
+ - ```
192
+
193
+ ```
194
+
195
+ -
196
+ - Now what do the contents of our `animator` variable look like:
197
+ -
198
+ - ```js
199
+
200
+ ```
201
+
202
+ - {
203
+ - // starts the animation
204
+ - start: Function,
205
+ -
206
+ - // ends (aborts) the animation
207
+ - end: Function
208
+ - }
209
+ - ```
210
+
211
+ ```
212
+
213
+ -
214
+ - To actually start the animation we need to run `animation.start()` which will then return a promise that we can hook into to detect when the animation ends.
215
+ - If we choose not to run the animation then we MUST run `animation.end()` to perform a cleanup on the element (since some CSS classes and styles may have been
216
+ - applied to the element during the preparation phase). Note that all other properties such as duration, delay, transitions and keyframes are just properties
217
+ - and that changing them will not reconfigure the parameters of the animation.
218
+ -
219
+ - ### runner.done() vs runner.then()
220
+ - It is documented that `animation.start()` will return a promise object and this is true, however, there is also an additional method available on the
221
+ - runner called `.done(callbackFn)`. The done method works the same as `.finally(callbackFn)`, however, it does **not trigger a digest to occur**.
222
+ - Therefore, for performance reasons, it's always best to use `runner.done(callback)` instead of `runner.then()`, `runner.catch()` or `runner.finally()`
223
+ - unless you really need a digest to kick off afterwards.
224
+ -
225
+ - Keep in mind that, to make this easier, ngAnimate has tweaked the JS animations API to recognize when a runner instance is returned from $animateCss
226
+ - (so there is no need to call `runner.done(doneFn)` inside of your JavaScript animation code).
227
+ - Check the {@link ngAnimate.$animateCss#usage animation code above} to see how this works.
228
+ -
229
+ - @param {Element} element the element that will be animated
230
+ - @param {object} options the animation-related options that will be applied during the animation
231
+ -
232
+ - - `event` - The DOM event (e.g. enter, leave, move). When used, a generated CSS class of `ng-EVENT` and `ng-EVENT-active` will be applied
233
+ - to the element during the animation. Multiple events can be provided when spaces are used as a separator. (Note that this will not perform any DOM operation.)
234
+ - - `structural` - Indicates that the `ng-` prefix will be added to the event class. Setting to `false` or omitting will turn `ng-EVENT` and
235
+ - `ng-EVENT-active` in `EVENT` and `EVENT-active`. Unused if `event` is omitted.
236
+ - - `easing` - The CSS easing value that will be applied to the transition or keyframe animation (or both).
237
+ - - `transitionStyle` - The raw CSS transition style that will be used (e.g. `1s linear all`).
238
+ - - `keyframeStyle` - The raw CSS keyframe animation style that will be used (e.g. `1s my_animation linear`).
239
+ - - `from` - The starting CSS styles (a key/value object) that will be applied at the start of the animation.
240
+ - - `to` - The ending CSS styles (a key/value object) that will be applied across the animation via a CSS transition.
241
+ - - `addClass` - A space separated list of CSS classes that will be added to the element and spread across the animation.
242
+ - - `removeClass` - A space separated list of CSS classes that will be removed from the element and spread across the animation.
243
+ - - `duration` - A number value representing the total duration of the transition and/or keyframe (note that a value of 1 is 1000ms). If a value of `0`
244
+ - is provided then the animation will be skipped entirely.
245
+ - - `delay` - A number value representing the total delay of the transition and/or keyframe (note that a value of 1 is 1000ms). If a value of `true` is
246
+ - used then whatever delay value is detected from the CSS classes will be mirrored on the elements styles (e.g. by setting delay true then the style value
247
+ - of the element will be `transition-delay: DETECTED_VALUE`). Using `true` is useful when you want the CSS classes and inline styles to all share the same
248
+ - CSS delay value.
249
+ - - `stagger` - A numeric time value representing the delay between successively animated elements
250
+ - ({@link ngAnimate#css-staggering-animations Click here to learn how CSS-based staggering works in ngAnimate.})
251
+ - - `staggerIndex` - The numeric index representing the stagger item (e.g. a value of 5 is equal to the sixth item in the stagger; therefore when a
252
+ - `stagger` option value of `0.1` is used then there will be a stagger delay of `600ms`)
253
+ - - `applyClassesEarly` - Whether or not the classes being added or removed will be used when detecting the animation. This is set by `$animate` when enter/leave/move animations are fired to ensure that the CSS classes are resolved in time. (Note that this will prevent any transitions from occurring on the classes being added and removed.)
254
+ - - `cleanupStyles` - Whether or not the provided `from` and `to` styles will be removed once
255
+ - the animation is closed. This is useful for when the styles are used purely for the sake of
256
+ - the animation and do not have a lasting visual effect on the element (e.g. a collapse and open animation).
257
+ - By default this value is set to `false`.
258
+ -
259
+ - @return {object} an object with start and end methods and details about the animation.
260
+ -
261
+ - - `start` - The method to start the animation. This will return a `Promise` when called.
262
+ - - `end` - This method will cancel the animation and remove all applied CSS classes and styles.
263
+ \*/