@angular-wave/angular.ts 0.0.51 → 0.0.53

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 (42) hide show
  1. package/dist/angular-ts.esm.js +2 -2
  2. package/dist/angular-ts.umd.js +2 -2
  3. package/package.json +1 -1
  4. package/src/animations/animate-children-directive.js +19 -99
  5. package/src/animations/animate-children-directive.md +80 -0
  6. package/src/animations/animate-css-driver.js +250 -256
  7. package/src/animations/animate-css.js +646 -875
  8. package/src/animations/animate-css.md +263 -0
  9. package/src/animations/animate-js-driver.js +54 -56
  10. package/src/animations/animate-js.js +303 -306
  11. package/src/animations/animate-queue.js +707 -716
  12. package/src/animations/animate-swap.js +30 -119
  13. package/src/animations/animate-swap.md +88 -0
  14. package/src/animations/animation.js +3 -3
  15. package/src/core/animate/animate-css.js +21 -6
  16. package/src/core/animate/animate-runner.js +147 -145
  17. package/src/core/animate/animate.js +572 -585
  18. package/src/core/animate/animate.spec.js +194 -286
  19. package/src/core/animate/anomate.md +13 -0
  20. package/src/core/animate/helpers.js +10 -0
  21. package/src/core/compile/compile.spec.js +5 -6
  22. package/src/core/core.html +0 -1
  23. package/src/directive/select/select.js +301 -305
  24. package/src/public.js +0 -1
  25. package/src/router/directives/state-directives.js +256 -574
  26. package/src/router/directives/state-directives.md +435 -0
  27. package/src/router/directives/view-directive.js +3 -3
  28. package/src/router/index.js +7 -7
  29. package/types/animations/animate-children-directive.d.ts +5 -80
  30. package/types/animations/animate-css-driver.d.ts +11 -0
  31. package/types/animations/animate-css.d.ts +8 -0
  32. package/types/animations/animate-js-driver.d.ts +8 -0
  33. package/types/animations/animate-js.d.ts +12 -0
  34. package/types/animations/animate-queue.d.ts +19 -0
  35. package/types/animations/animate-swap.d.ts +5 -89
  36. package/types/core/animate/animate-css.d.ts +1 -1
  37. package/types/core/animate/animate-runner.d.ts +32 -0
  38. package/types/core/animate/animate.d.ts +509 -0
  39. package/types/core/animate/helpers.d.ts +8 -0
  40. package/types/directive/select/select.d.ts +79 -0
  41. package/types/router/directives/state-directives.d.ts +31 -0
  42. package/src/core/document.spec.js +0 -52
@@ -7,9 +7,10 @@ import {
7
7
  extend,
8
8
  } from "../../shared/utils";
9
9
  import { JQLite } from "../../shared/jqlite/jqlite";
10
+ import { NG_ANIMATE_CLASSNAME } from "../../animations/shared";
11
+ import { addInlineStyles } from "./helpers";
10
12
 
11
13
  const $animateMinErr = minErr("$animate");
12
- const NG_ANIMATE_CLASSNAME = "ng-animate";
13
14
 
14
15
  function mergeClasses(a, b) {
15
16
  if (!a && !b) return "";
@@ -86,10 +87,10 @@ export function CoreAnimateQueueProvider() {
86
87
 
87
88
  options = options || {};
88
89
  if (options.from) {
89
- //element.css(options.from);
90
+ addInlineStyles(element[0], options.from);
90
91
  }
91
92
  if (options.to) {
92
- //element.css(options.to);
93
+ addInlineStyles(element[0], options.to);
93
94
  }
94
95
 
95
96
  if (options.addClass || options.removeClass) {
@@ -150,7 +151,7 @@ export function CoreAnimateQueueProvider() {
150
151
  toRemove.split(" ").forEach((css) => elm.classList.remove(css));
151
152
  }
152
153
  if (toAdd) {
153
- elm.className += ` ${toAdd}`;
154
+ toAdd.split(" ").forEach((css) => elm.classList.add(css));
154
155
  }
155
156
  });
156
157
  postDigestQueue.delete(element);
@@ -178,345 +179,332 @@ export function CoreAnimateQueueProvider() {
178
179
  ];
179
180
  }
180
181
 
181
- /**
182
- * @ngdoc provider
183
- * @name $animateProvider
184
- *
185
- * @description
186
- * Default implementation of $animate that doesn't perform any animations, instead just
187
- * synchronously performs DOM updates and resolves the returned runner promise.
188
- *
189
- * In order to enable animations the `ngAnimate` module has to be loaded.
190
- *
191
- * To see the functional implementation check out `src/ngAnimate/animate.js`.
192
- */
193
- export const AnimateProvider = [
194
- "$provide",
195
- function ($provide) {
196
- const provider = this;
197
- let classNameFilter = null;
198
- let customFilter = null;
199
-
200
- this.$$registeredAnimations = Object.create(null);
201
-
202
- /**
203
- * @ngdoc method
204
- * @name $animateProvider#register
205
- *
206
- * @description
207
- * Registers a new injectable animation factory function. The factory function produces the
208
- * animation object which contains callback functions for each event that is expected to be
209
- * animated.
210
- *
211
- * * `eventFn`: `function(element, ... , doneFunction, options)`
212
- * The element to animate, the `doneFunction` and the options fed into the animation. Depending
213
- * on the type of animation additional arguments will be injected into the animation function. The
214
- * list below explains the function signatures for the different animation methods:
215
- *
216
- * - setClass: function(element, addedClasses, removedClasses, doneFunction, options)
217
- * - addClass: function(element, addedClasses, doneFunction, options)
218
- * - removeClass: function(element, removedClasses, doneFunction, options)
219
- * - enter, leave, move: function(element, doneFunction, options)
220
- * - animate: function(element, fromStyles, toStyles, doneFunction, options)
221
- *
222
- * Make sure to trigger the `doneFunction` once the animation is fully complete.
223
- *
224
- * ```js
225
- * return {
226
- * //enter, leave, move signature
227
- * eventFn : function(element, done, options) {
228
- * //code to run the animation
229
- * //once complete, then run done()
230
- * return function endFunction(wasCancelled) {
231
- * //code to cancel the animation
232
- * }
233
- * }
234
- * }
235
- * ```
236
- *
237
- * @param {string} name The name of the animation (this is what the class-based CSS value will be compared to).
238
- * @param {Function} factory The factory function that will be executed to return the animation
239
- * object.
240
- */
241
- this.register = function (name, factory) {
242
- if (name && name.charAt(0) !== ".") {
243
- throw $animateMinErr(
244
- "notcsel",
245
- "Expecting class selector starting with '.' got '{0}'.",
246
- name,
247
- );
248
- }
182
+ AnimateProvider.$inject = ["$provide"];
183
+ export function AnimateProvider($provide) {
184
+ const provider = this;
185
+ let classNameFilter = null;
186
+ let customFilter = null;
187
+
188
+ this.$$registeredAnimations = Object.create(null);
189
+
190
+ /**
191
+ * @ngdoc method
192
+ * @name $animateProvider#register
193
+ *
194
+ * @description
195
+ * Registers a new injectable animation factory function. The factory function produces the
196
+ * animation object which contains callback functions for each event that is expected to be
197
+ * animated.
198
+ *
199
+ * * `eventFn`: `function(element, ... , doneFunction, options)`
200
+ * The element to animate, the `doneFunction` and the options fed into the animation. Depending
201
+ * on the type of animation additional arguments will be injected into the animation function. The
202
+ * list below explains the function signatures for the different animation methods:
203
+ *
204
+ * - setClass: function(element, addedClasses, removedClasses, doneFunction, options)
205
+ * - addClass: function(element, addedClasses, doneFunction, options)
206
+ * - removeClass: function(element, removedClasses, doneFunction, options)
207
+ * - enter, leave, move: function(element, doneFunction, options)
208
+ * - animate: function(element, fromStyles, toStyles, doneFunction, options)
209
+ *
210
+ * Make sure to trigger the `doneFunction` once the animation is fully complete.
211
+ *
212
+ * ```js
213
+ * return {
214
+ * //enter, leave, move signature
215
+ * eventFn : function(element, done, options) {
216
+ * //code to run the animation
217
+ * //once complete, then run done()
218
+ * return function endFunction(wasCancelled) {
219
+ * //code to cancel the animation
220
+ * }
221
+ * }
222
+ * }
223
+ * ```
224
+ *
225
+ * @param {string} name The name of the animation (this is what the class-based CSS value will be compared to).
226
+ * @param {Function} factory The factory function that will be executed to return the animation
227
+ * object.
228
+ */
229
+ this.register = function (name, factory) {
230
+ if (name && name.charAt(0) !== ".") {
231
+ throw $animateMinErr(
232
+ "notcsel",
233
+ "Expecting class selector starting with '.' got '{0}'.",
234
+ name,
235
+ );
236
+ }
249
237
 
250
- const key = `${name}-animation`;
251
- provider.$$registeredAnimations[name.substr(1)] = key;
252
- $provide.factory(key, factory);
253
- };
254
-
255
- /**
256
- * @ngdoc method
257
- * @name $animateProvider#customFilter
258
- *
259
- * @description
260
- * Sets and/or returns the custom filter function that is used to "filter" animations, i.e.
261
- * determine if an animation is allowed or not. When no filter is specified (the default), no
262
- * animation will be blocked. Setting the `customFilter` value will only allow animations for
263
- * which the filter function's return value is truthy.
264
- *
265
- * This allows to easily create arbitrarily complex rules for filtering animations, such as
266
- * allowing specific events only, or enabling animations on specific subtrees of the DOM, etc.
267
- * Filtering animations can also boost performance for low-powered devices, as well as
268
- * applications containing a lot of structural operations.
269
- *
270
- * <div class="alert alert-success">
271
- * **Best Practice:**
272
- * Keep the filtering function as lean as possible, because it will be called for each DOM
273
- * action (e.g. insertion, removal, class change) performed by "animation-aware" directives.
274
- * See {@link guide/animations#which-directives-support-animations- here} for a list of built-in
275
- * directives that support animations.
276
- * Performing computationally expensive or time-consuming operations on each call of the
277
- * filtering function can make your animations sluggish.
278
- * </div>
279
- *
280
- * **Note:** If present, `customFilter` will be checked before
281
- * {@link $animateProvider#classNameFilter classNameFilter}.
282
- *
283
- * @param {Function=} filterFn - The filter function which will be used to filter all animations.
284
- * If a falsy value is returned, no animation will be performed. The function will be called
285
- * with the following arguments:
286
- * - **node** `{Element}` - The DOM element to be animated.
287
- * - **event** `{String}` - The name of the animation event (e.g. `enter`, `leave`, `addClass`
288
- * etc).
289
- * - **options** `{Object}` - A collection of options/styles used for the animation.
290
- * @return {Function} The current filter function or `null` if there is none set.
291
- */
292
- this.customFilter = function (filterFn) {
293
- if (arguments.length === 1) {
294
- customFilter = isFunction(filterFn) ? filterFn : null;
295
- }
238
+ const key = `${name}-animation`;
239
+ provider.$$registeredAnimations[name.substr(1)] = key;
240
+ $provide.factory(key, factory);
241
+ };
242
+
243
+ /**
244
+ * @ngdoc method
245
+ * @name $animateProvider#customFilter
246
+ *
247
+ * @description
248
+ * Sets and/or returns the custom filter function that is used to "filter" animations, i.e.
249
+ * determine if an animation is allowed or not. When no filter is specified (the default), no
250
+ * animation will be blocked. Setting the `customFilter` value will only allow animations for
251
+ * which the filter function's return value is truthy.
252
+ *
253
+ * This allows to easily create arbitrarily complex rules for filtering animations, such as
254
+ * allowing specific events only, or enabling animations on specific subtrees of the DOM, etc.
255
+ * Filtering animations can also boost performance for low-powered devices, as well as
256
+ * applications containing a lot of structural operations.
257
+ *
258
+ * <div class="alert alert-success">
259
+ * **Best Practice:**
260
+ * Keep the filtering function as lean as possible, because it will be called for each DOM
261
+ * action (e.g. insertion, removal, class change) performed by "animation-aware" directives.
262
+ * See {@link guide/animations#which-directives-support-animations- here} for a list of built-in
263
+ * directives that support animations.
264
+ * Performing computationally expensive or time-consuming operations on each call of the
265
+ * filtering function can make your animations sluggish.
266
+ * </div>
267
+ *
268
+ * **Note:** If present, `customFilter` will be checked before
269
+ * {@link $animateProvider#classNameFilter classNameFilter}.
270
+ *
271
+ * @param {Function=} filterFn - The filter function which will be used to filter all animations.
272
+ * If a falsy value is returned, no animation will be performed. The function will be called
273
+ * with the following arguments:
274
+ * - **node** `{Element}` - The DOM element to be animated.
275
+ * - **event** `{String}` - The name of the animation event (e.g. `enter`, `leave`, `addClass`
276
+ * etc).
277
+ * - **options** `{Object}` - A collection of options/styles used for the animation.
278
+ * @return {Function} The current filter function or `null` if there is none set.
279
+ */
280
+ this.customFilter = function (filterFn) {
281
+ if (arguments.length === 1) {
282
+ customFilter = isFunction(filterFn) ? filterFn : null;
283
+ }
296
284
 
297
- return customFilter;
298
- };
299
-
300
- /**
301
- * @ngdoc method
302
- * @name $animateProvider#classNameFilter
303
- *
304
- * @description
305
- * Sets and/or returns the CSS class regular expression that is checked when performing
306
- * an animation. Upon bootstrap the classNameFilter value is not set at all and will
307
- * therefore enable $animate to attempt to perform an animation on any element that is triggered.
308
- * When setting the `classNameFilter` value, animations will only be performed on elements
309
- * that successfully match the filter expression. This in turn can boost performance
310
- * for low-powered devices as well as applications containing a lot of structural operations.
311
- *
312
- * **Note:** If present, `classNameFilter` will be checked after
313
- * {@link $animateProvider#customFilter customFilter}. If `customFilter` is present and returns
314
- * false, `classNameFilter` will not be checked.
315
- *
316
- * @param {RegExp=} expression The className expression which will be checked against all animations
317
- * @return {RegExp} The current CSS className expression value. If null then there is no expression value
318
- */
319
- this.classNameFilter = function (expression) {
320
- if (arguments.length === 1) {
321
- classNameFilter = expression instanceof RegExp ? expression : null;
322
- if (classNameFilter) {
323
- const reservedRegex = new RegExp(
324
- `[(\\s|\\/)]${NG_ANIMATE_CLASSNAME}[(\\s|\\/)]`,
285
+ return customFilter;
286
+ };
287
+
288
+ /**
289
+ * @ngdoc method
290
+ * @name $animateProvider#classNameFilter
291
+ *
292
+ * @description
293
+ * Sets and/or returns the CSS class regular expression that is checked when performing
294
+ * an animation. Upon bootstrap the classNameFilter value is not set at all and will
295
+ * therefore enable $animate to attempt to perform an animation on any element that is triggered.
296
+ * When setting the `classNameFilter` value, animations will only be performed on elements
297
+ * that successfully match the filter expression. This in turn can boost performance
298
+ * for low-powered devices as well as applications containing a lot of structural operations.
299
+ *
300
+ * **Note:** If present, `classNameFilter` will be checked after
301
+ * {@link $animateProvider#customFilter customFilter}. If `customFilter` is present and returns
302
+ * false, `classNameFilter` will not be checked.
303
+ *
304
+ * @param {RegExp=} expression The className expression which will be checked against all animations
305
+ * @return {RegExp} The current CSS className expression value. If null then there is no expression value
306
+ */
307
+ this.classNameFilter = function (expression) {
308
+ if (arguments.length === 1) {
309
+ classNameFilter = expression instanceof RegExp ? expression : null;
310
+ if (classNameFilter) {
311
+ const reservedRegex = new RegExp(
312
+ `[(\\s|\\/)]${NG_ANIMATE_CLASSNAME}[(\\s|\\/)]`,
313
+ );
314
+ if (reservedRegex.test(classNameFilter.toString())) {
315
+ classNameFilter = null;
316
+ throw $animateMinErr(
317
+ "nongcls",
318
+ '$animateProvider.classNameFilter(regex) prohibits accepting a regex value which matches/contains the "{0}" CSS class.',
319
+ NG_ANIMATE_CLASSNAME,
325
320
  );
326
- if (reservedRegex.test(classNameFilter.toString())) {
327
- classNameFilter = null;
328
- throw $animateMinErr(
329
- "nongcls",
330
- '$animateProvider.classNameFilter(regex) prohibits accepting a regex value which matches/contains the "{0}" CSS class.',
331
- NG_ANIMATE_CLASSNAME,
332
- );
333
- }
334
321
  }
335
322
  }
336
- return classNameFilter;
337
- };
338
-
339
- this.$get = [
340
- "$$animateQueue",
341
- function ($$animateQueue) {
342
- function domInsert(element, parentElement, afterElement) {
343
- // if for some reason the previous element was removed
344
- // from the dom sometime before this code runs then let's
345
- // just stick to using the parent element as the anchor
346
- if (afterElement) {
347
- const afterNode = extractElementNode(afterElement);
348
- if (
349
- afterNode &&
350
- !afterNode.parentNode &&
351
- !afterNode.previousElementSibling
352
- ) {
353
- afterElement = null;
354
- }
355
- }
356
- if (afterElement) {
357
- afterElement.after(element);
358
- } else {
359
- parentElement.prepend(element);
323
+ }
324
+ return classNameFilter;
325
+ };
326
+
327
+ this.$get = [
328
+ "$$animateQueue",
329
+ function ($$animateQueue) {
330
+ function domInsert(element, parentElement, afterElement) {
331
+ // if for some reason the previous element was removed
332
+ // from the dom sometime before this code runs then let's
333
+ // just stick to using the parent element as the anchor
334
+ if (afterElement) {
335
+ const afterNode = extractElementNode(afterElement);
336
+ if (
337
+ afterNode &&
338
+ !afterNode.parentNode &&
339
+ !afterNode.previousElementSibling
340
+ ) {
341
+ afterElement = null;
360
342
  }
361
343
  }
344
+ if (afterElement) {
345
+ afterElement.after(element);
346
+ } else {
347
+ parentElement.prepend(element);
348
+ }
349
+ }
350
+
351
+ /**
352
+ * @ngdoc service
353
+ * @name $animate
354
+ * @description The $animate service exposes a series of DOM utility methods that provide support
355
+ * for animation hooks. The default behavior is the application of DOM operations, however,
356
+ * when an animation is detected (and animations are enabled), $animate will do the heavy lifting
357
+ * to ensure that animation runs with the triggered DOM operation.
358
+ *
359
+ * By default $animate doesn't trigger any animations. This is because the `ngAnimate` module isn't
360
+ * included and only when it is active then the animation hooks that `$animate` triggers will be
361
+ * functional. Once active then all structural `ng-` directives will trigger animations as they perform
362
+ * their DOM-related operations (enter, leave and move). Other directives such as `ngClass`,
363
+ * `ngShow`, `ngHide` and `ngMessages` also provide support for animations.
364
+ *
365
+ * It is recommended that the`$animate` service is always used when executing DOM-related procedures within directives.
366
+ *
367
+ * To learn more about enabling animation support, click here to visit the
368
+ * {@link ngAnimate ngAnimate module page}.
369
+ */
370
+ return {
371
+ // we don't call it directly since non-existant arguments may
372
+ // be interpreted as null within the sub enabled function
373
+
374
+ /**
375
+ *
376
+ * @ngdoc method
377
+ * @name $animate#on
378
+ * @kind function
379
+ * @description Sets up an event listener to fire whenever the animation event (enter, leave, move, etc...)
380
+ * has fired on the given element or among any of its children. Once the listener is fired, the provided callback
381
+ * is fired with the following params:
382
+ *
383
+ * ```js
384
+ * $animate.on('enter', container,
385
+ * function callback(element, phase) {
386
+ * // cool we detected an enter animation within the container
387
+ * }
388
+ * );
389
+ * ```
390
+ *
391
+ * <div class="alert alert-warning">
392
+ * **Note**: Generally, the events that are fired correspond 1:1 to `$animate` method names,
393
+ * e.g. {@link ng.$animate#addClass addClass()} will fire `addClass`, and {@link ng.ngClass}
394
+ * will fire `addClass` if classes are added, and `removeClass` if classes are removed.
395
+ * However, there are two exceptions:
396
+ *
397
+ * <ul>
398
+ * <li>if both an {@link ng.$animate#addClass addClass()} and a
399
+ * {@link ng.$animate#removeClass removeClass()} action are performed during the same
400
+ * animation, the event fired will be `setClass`. This is true even for `ngClass`.</li>
401
+ * <li>an {@link ng.$animate#animate animate()} call that adds and removes classes will fire
402
+ * the `setClass` event, but if it either removes or adds classes,
403
+ * it will fire `animate` instead.</li>
404
+ * </ul>
405
+ *
406
+ * </div>
407
+ *
408
+ * @param {string} event the animation event that will be captured (e.g. enter, leave, move, addClass, removeClass, etc...)
409
+ * @param {Element} container the container element that will capture each of the animation events that are fired on itself
410
+ * as well as among its children
411
+ * @param {Function} callback the callback function that will be fired when the listener is triggered.
412
+ *
413
+ * The arguments present in the callback function are:
414
+ * * `element` - The captured DOM element that the animation was fired on.
415
+ * * `phase` - The phase of the animation. The two possible phases are **start** (when the animation starts) and **close** (when it ends).
416
+ * * `data` - an object with these properties:
417
+ * * addClass - `{string|null}` - space-separated CSS classes to add to the element
418
+ * * removeClass - `{string|null}` - space-separated CSS classes to remove from the element
419
+ * * from - `{Object|null}` - CSS properties & values at the beginning of the animation
420
+ * * to - `{Object|null}` - CSS properties & values at the end of the animation
421
+ *
422
+ * Note that the callback does not trigger a scope digest. Wrap your call into a
423
+ * {@link $rootScope.Scope#$apply scope.$apply} to propagate changes to the scope.
424
+ */
425
+ on: $$animateQueue.on,
362
426
 
363
427
  /**
364
- * @ngdoc service
365
- * @name $animate
366
- * @description The $animate service exposes a series of DOM utility methods that provide support
367
- * for animation hooks. The default behavior is the application of DOM operations, however,
368
- * when an animation is detected (and animations are enabled), $animate will do the heavy lifting
369
- * to ensure that animation runs with the triggered DOM operation.
370
- *
371
- * By default $animate doesn't trigger any animations. This is because the `ngAnimate` module isn't
372
- * included and only when it is active then the animation hooks that `$animate` triggers will be
373
- * functional. Once active then all structural `ng-` directives will trigger animations as they perform
374
- * their DOM-related operations (enter, leave and move). Other directives such as `ngClass`,
375
- * `ngShow`, `ngHide` and `ngMessages` also provide support for animations.
376
- *
377
- * It is recommended that the`$animate` service is always used when executing DOM-related procedures within directives.
378
- *
379
- * To learn more about enabling animation support, click here to visit the
380
- * {@link ngAnimate ngAnimate module page}.
428
+ *
429
+ * @ngdoc method
430
+ * @name $animate#off
431
+ * @kind function
432
+ * @description Deregisters an event listener based on the event which has been associated with the provided element. This method
433
+ * can be used in three different ways depending on the arguments:
434
+ *
435
+ * ```js
436
+ * // remove all the animation event listeners listening for `enter`
437
+ * $animate.off('enter');
438
+ *
439
+ * // remove listeners for all animation events from the container element
440
+ * $animate.off(container);
441
+ *
442
+ * // remove all the animation event listeners listening for `enter` on the given element and its children
443
+ * $animate.off('enter', container);
444
+ *
445
+ * // remove the event listener function provided by `callback` that is set
446
+ * // to listen for `enter` on the given `container` as well as its children
447
+ * $animate.off('enter', container, callback);
448
+ * ```
449
+ *
450
+ * @param {string|Element} event|container the animation event (e.g. enter, leave, move,
451
+ * addClass, removeClass, etc...), or the container element. If it is the element, all other
452
+ * arguments are ignored.
453
+ * @param {Element=} container the container element the event listener was placed on
454
+ * @param {Function=} callback the callback function that was registered as the listener
455
+ */
456
+ off: $$animateQueue.off,
457
+
458
+ /**
459
+ * @ngdoc method
460
+ * @name $animate#pin
461
+ * @kind function
462
+ * @description Associates the provided element with a host parent element to allow the element to be animated even if it exists
463
+ * outside of the DOM structure of the AngularJS application. By doing so, any animation triggered via `$animate` can be issued on the
464
+ * element despite being outside the realm of the application or within another application. Say for example if the application
465
+ * was bootstrapped on an element that is somewhere inside of the `<body>` tag, but we wanted to allow for an element to be situated
466
+ * as a direct child of `document.body`, then this can be achieved by pinning the element via `$animate.pin(element)`. Keep in mind
467
+ * that calling `$animate.pin(element, parentElement)` will not actually insert into the DOM anywhere; it will just create the association.
468
+ *
469
+ * Note that this feature is only active when the `ngAnimate` module is used.
470
+ *
471
+ * @param {Element} element the external element that will be pinned
472
+ * @param {Element} parentElement the host parent element that will be associated with the external element
473
+ */
474
+ pin: $$animateQueue.pin,
475
+
476
+ /**
477
+ *
478
+ * @ngdoc method
479
+ * @name $animate#enabled
480
+ * @kind function
481
+ * @description Used to get and set whether animations are enabled or not on the entire application or on an element and its children. This
482
+ * function can be called in four ways:
483
+ *
484
+ * ```js
485
+ * // returns true or false
486
+ * $animate.enabled();
487
+ *
488
+ * // changes the enabled state for all animations
489
+ * $animate.enabled(false);
490
+ * $animate.enabled(true);
491
+ *
492
+ * // returns true or false if animations are enabled for an element
493
+ * $animate.enabled(element);
494
+ *
495
+ * // changes the enabled state for an element and its children
496
+ * $animate.enabled(element, true);
497
+ * $animate.enabled(element, false);
498
+ * ```
499
+ *
500
+ * @param {Element=} element the element that will be considered for checking/setting the enabled state
501
+ * @param {boolean=} enabled whether or not the animations will be enabled for the element
502
+ *
503
+ * @return {boolean} whether or not animations are enabled
381
504
  */
382
- return {
383
- // we don't call it directly since non-existant arguments may
384
- // be interpreted as null within the sub enabled function
385
-
386
- /**
387
- *
388
- * @ngdoc method
389
- * @name $animate#on
390
- * @kind function
391
- * @description Sets up an event listener to fire whenever the animation event (enter, leave, move, etc...)
392
- * has fired on the given element or among any of its children. Once the listener is fired, the provided callback
393
- * is fired with the following params:
394
- *
395
- * ```js
396
- * $animate.on('enter', container,
397
- * function callback(element, phase) {
398
- * // cool we detected an enter animation within the container
399
- * }
400
- * );
401
- * ```
402
- *
403
- * <div class="alert alert-warning">
404
- * **Note**: Generally, the events that are fired correspond 1:1 to `$animate` method names,
405
- * e.g. {@link ng.$animate#addClass addClass()} will fire `addClass`, and {@link ng.ngClass}
406
- * will fire `addClass` if classes are added, and `removeClass` if classes are removed.
407
- * However, there are two exceptions:
408
- *
409
- * <ul>
410
- * <li>if both an {@link ng.$animate#addClass addClass()} and a
411
- * {@link ng.$animate#removeClass removeClass()} action are performed during the same
412
- * animation, the event fired will be `setClass`. This is true even for `ngClass`.</li>
413
- * <li>an {@link ng.$animate#animate animate()} call that adds and removes classes will fire
414
- * the `setClass` event, but if it either removes or adds classes,
415
- * it will fire `animate` instead.</li>
416
- * </ul>
417
- *
418
- * </div>
419
- *
420
- * @param {string} event the animation event that will be captured (e.g. enter, leave, move, addClass, removeClass, etc...)
421
- * @param {Element} container the container element that will capture each of the animation events that are fired on itself
422
- * as well as among its children
423
- * @param {Function} callback the callback function that will be fired when the listener is triggered.
424
- *
425
- * The arguments present in the callback function are:
426
- * * `element` - The captured DOM element that the animation was fired on.
427
- * * `phase` - The phase of the animation. The two possible phases are **start** (when the animation starts) and **close** (when it ends).
428
- * * `data` - an object with these properties:
429
- * * addClass - `{string|null}` - space-separated CSS classes to add to the element
430
- * * removeClass - `{string|null}` - space-separated CSS classes to remove from the element
431
- * * from - `{Object|null}` - CSS properties & values at the beginning of the animation
432
- * * to - `{Object|null}` - CSS properties & values at the end of the animation
433
- *
434
- * Note that the callback does not trigger a scope digest. Wrap your call into a
435
- * {@link $rootScope.Scope#$apply scope.$apply} to propagate changes to the scope.
436
- */
437
- on: $$animateQueue.on,
438
-
439
- /**
440
- *
441
- * @ngdoc method
442
- * @name $animate#off
443
- * @kind function
444
- * @description Deregisters an event listener based on the event which has been associated with the provided element. This method
445
- * can be used in three different ways depending on the arguments:
446
- *
447
- * ```js
448
- * // remove all the animation event listeners listening for `enter`
449
- * $animate.off('enter');
450
- *
451
- * // remove listeners for all animation events from the container element
452
- * $animate.off(container);
453
- *
454
- * // remove all the animation event listeners listening for `enter` on the given element and its children
455
- * $animate.off('enter', container);
456
- *
457
- * // remove the event listener function provided by `callback` that is set
458
- * // to listen for `enter` on the given `container` as well as its children
459
- * $animate.off('enter', container, callback);
460
- * ```
461
- *
462
- * @param {string|Element} event|container the animation event (e.g. enter, leave, move,
463
- * addClass, removeClass, etc...), or the container element. If it is the element, all other
464
- * arguments are ignored.
465
- * @param {Element=} container the container element the event listener was placed on
466
- * @param {Function=} callback the callback function that was registered as the listener
467
- */
468
- off: $$animateQueue.off,
469
-
470
- /**
471
- * @ngdoc method
472
- * @name $animate#pin
473
- * @kind function
474
- * @description Associates the provided element with a host parent element to allow the element to be animated even if it exists
475
- * outside of the DOM structure of the AngularJS application. By doing so, any animation triggered via `$animate` can be issued on the
476
- * element despite being outside the realm of the application or within another application. Say for example if the application
477
- * was bootstrapped on an element that is somewhere inside of the `<body>` tag, but we wanted to allow for an element to be situated
478
- * as a direct child of `document.body`, then this can be achieved by pinning the element via `$animate.pin(element)`. Keep in mind
479
- * that calling `$animate.pin(element, parentElement)` will not actually insert into the DOM anywhere; it will just create the association.
480
- *
481
- * Note that this feature is only active when the `ngAnimate` module is used.
482
- *
483
- * @param {Element} element the external element that will be pinned
484
- * @param {Element} parentElement the host parent element that will be associated with the external element
485
- */
486
- pin: $$animateQueue.pin,
487
-
488
- /**
489
- *
490
- * @ngdoc method
491
- * @name $animate#enabled
492
- * @kind function
493
- * @description Used to get and set whether animations are enabled or not on the entire application or on an element and its children. This
494
- * function can be called in four ways:
495
- *
496
- * ```js
497
- * // returns true or false
498
- * $animate.enabled();
499
- *
500
- * // changes the enabled state for all animations
501
- * $animate.enabled(false);
502
- * $animate.enabled(true);
503
- *
504
- * // returns true or false if animations are enabled for an element
505
- * $animate.enabled(element);
506
- *
507
- * // changes the enabled state for an element and its children
508
- * $animate.enabled(element, true);
509
- * $animate.enabled(element, false);
510
- * ```
511
- *
512
- * @param {Element=} element the element that will be considered for checking/setting the enabled state
513
- * @param {boolean=} enabled whether or not the animations will be enabled for the element
514
- *
515
- * @return {boolean} whether or not animations are enabled
516
- */
517
- enabled: $$animateQueue.enabled,
518
-
519
- /**
505
+ enabled: $$animateQueue.enabled,
506
+
507
+ /**
520
508
  * @ngdoc method
521
509
  * @name $animate#cancel
522
510
  * @kind function
@@ -588,255 +576,254 @@ export const AnimateProvider = [
588
576
  </file>
589
577
  </example>
590
578
  */
591
- cancel(runner) {
592
- if (runner.cancel) {
593
- runner.cancel();
594
- }
595
- },
596
-
597
- /**
598
- *
599
- * @ngdoc method
600
- * @name $animate#enter
601
- * @kind function
602
- * @description Inserts the element into the DOM either after the `after` element (if provided) or
603
- * as the first child within the `parent` element and then triggers an animation.
604
- * A promise is returned that will be resolved during the next digest once the animation
605
- * has completed.
606
- *
607
- * @param {Element} element the element which will be inserted into the DOM
608
- * @param {Element} parent the parent element which will append the element as
609
- * a child (so long as the after element is not present)
610
- * @param {Element=} after the sibling element after which the element will be appended
611
- * @param {object=} options an optional collection of options/styles that will be applied to the element.
612
- * The object can have the following properties:
613
- *
614
- * - **addClass** - `{string}` - space-separated CSS classes to add to element
615
- * - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
616
- * - **removeClass** - `{string}` - space-separated CSS classes to remove from element
617
- * - **to** - `{Object}` - CSS properties & values at end of animation. Must have matching `from`
618
- *
619
- * @return {Runner} the animation runner
620
- */
621
- enter(element, parent, after, options) {
622
- parent = parent && JQLite(parent);
623
- after = after && JQLite(after);
624
- parent = parent || after.parent();
625
- domInsert(element, parent, after);
626
- return $$animateQueue.push(
627
- element,
628
- "enter",
629
- prepareAnimateOptions(options),
630
- );
631
- },
632
-
633
- /**
634
- *
635
- * @ngdoc method
636
- * @name $animate#move
637
- * @kind function
638
- * @description Inserts (moves) the element into its new position in the DOM either after
639
- * the `after` element (if provided) or as the first child within the `parent` element
640
- * and then triggers an animation. A promise is returned that will be resolved
641
- * during the next digest once the animation has completed.
642
- *
643
- * @param {Element} element the element which will be moved into the new DOM position
644
- * @param {Element} parent the parent element which will append the element as
645
- * a child (so long as the after element is not present)
646
- * @param {Element=} after the sibling element after which the element will be appended
647
- * @param {object=} options an optional collection of options/styles that will be applied to the element.
648
- * The object can have the following properties:
649
- *
650
- * - **addClass** - `{string}` - space-separated CSS classes to add to element
651
- * - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
652
- * - **removeClass** - `{string}` - space-separated CSS classes to remove from element
653
- * - **to** - `{Object}` - CSS properties & values at end of animation. Must have matching `from`
654
- *
655
- * @return {Runner} the animation runner
656
- */
657
- move(element, parent, after, options) {
658
- parent = parent && JQLite(parent);
659
- after = after && JQLite(after);
660
- parent = parent || after.parent();
661
- domInsert(element, parent, after);
662
- return $$animateQueue.push(
663
- element,
664
- "move",
665
- prepareAnimateOptions(options),
666
- );
667
- },
668
-
669
- /**
670
- * @ngdoc method
671
- * @name $animate#leave
672
- * @kind function
673
- * @description Triggers an animation and then removes the element from the DOM.
674
- * When the function is called a promise is returned that will be resolved during the next
675
- * digest once the animation has completed.
676
- *
677
- * @param {Element} element the element which will be removed from the DOM
678
- * @param {object=} options an optional collection of options/styles that will be applied to the element.
679
- * The object can have the following properties:
680
- *
681
- * - **addClass** - `{string}` - space-separated CSS classes to add to element
682
- * - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
683
- * - **removeClass** - `{string}` - space-separated CSS classes to remove from element
684
- * - **to** - `{Object}` - CSS properties & values at end of animation. Must have matching `from`
685
- *
686
- * @return {Runner} the animation runner
687
- */
688
- leave(element, options) {
689
- return $$animateQueue.push(
690
- element,
691
- "leave",
692
- prepareAnimateOptions(options),
693
- () => {
694
- element.remove();
695
- },
696
- );
697
- },
698
-
699
- /**
700
- * @ngdoc method
701
- * @name $animate#addClass
702
- * @kind function
703
- *
704
- * @description Triggers an addClass animation surrounding the addition of the provided CSS class(es). Upon
705
- * execution, the addClass operation will only be handled after the next digest and it will not trigger an
706
- * animation if element already contains the CSS class or if the class is removed at a later step.
707
- * Note that class-based animations are treated differently compared to structural animations
708
- * (like enter, move and leave) since the CSS classes may be added/removed at different points
709
- * depending if CSS or JavaScript animations are used.
710
- *
711
- * @param {Element} element the element which the CSS classes will be applied to
712
- * @param {string} className the CSS class(es) that will be added (multiple classes are separated via spaces)
713
- * @param {object=} options an optional collection of options/styles that will be applied to the element.
714
- * The object can have the following properties:
715
- *
716
- * - **removeClass** - `{string}` - space-separated CSS classes to remove from element
717
- * - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
718
- * - **to** - `{Object}` - CSS properties & values at end of animation. Must have matching `from`
719
- *
720
- * @return {Runner} animationRunner the animation runner
721
- */
722
- addClass(element, className, options) {
723
- options = prepareAnimateOptions(options);
724
- options.addClass = mergeClasses(options.addclass, className);
725
- return $$animateQueue.push(element, "addClass", options);
726
- },
727
-
728
- /**
729
- * @ngdoc method
730
- * @name $animate#removeClass
731
- * @kind function
732
- *
733
- * @description Triggers a removeClass animation surrounding the removal of the provided CSS class(es). Upon
734
- * execution, the removeClass operation will only be handled after the next digest and it will not trigger an
735
- * animation if element does not contain the CSS class or if the class is added at a later step.
736
- * Note that class-based animations are treated differently compared to structural animations
737
- * (like enter, move and leave) since the CSS classes may be added/removed at different points
738
- * depending if CSS or JavaScript animations are used.
739
- *
740
- * @param {Element} element the element which the CSS classes will be applied to
741
- * @param {string} className the CSS class(es) that will be removed (multiple classes are separated via spaces)
742
- * @param {object=} options an optional collection of options/styles that will be applied to the element.
743
- * The object can have the following properties:
744
- *
745
- * - **addClass** - `{string}` - space-separated CSS classes to add to element
746
- * - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
747
- * - **to** - `{Object}` - CSS properties & values at end of animation. Must have matching `from`
748
- *
749
- * @return {Runner} the animation runner
750
- */
751
- removeClass(element, className, options) {
752
- options = prepareAnimateOptions(options);
753
- options.removeClass = mergeClasses(options.removeClass, className);
754
- return $$animateQueue.push(element, "removeClass", options);
755
- },
756
-
757
- /**
758
- * @ngdoc method
759
- * @name $animate#setClass
760
- * @kind function
761
- *
762
- * @description Performs both the addition and removal of a CSS classes on an element and (during the process)
763
- * triggers an animation surrounding the class addition/removal. Much like `$animate.addClass` and
764
- * `$animate.removeClass`, `setClass` will only evaluate the classes being added/removed once a digest has
765
- * passed. Note that class-based animations are treated differently compared to structural animations
766
- * (like enter, move and leave) since the CSS classes may be added/removed at different points
767
- * depending if CSS or JavaScript animations are used.
768
- *
769
- * @param {Element} element the element which the CSS classes will be applied to
770
- * @param {string} add the CSS class(es) that will be added (multiple classes are separated via spaces)
771
- * @param {string} remove the CSS class(es) that will be removed (multiple classes are separated via spaces)
772
- * @param {object=} options an optional collection of options/styles that will be applied to the element.
773
- * The object can have the following properties:
774
- *
775
- * - **addClass** - `{string}` - space-separated CSS classes to add to element
776
- * - **removeClass** - `{string}` - space-separated CSS classes to remove from element
777
- * - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
778
- * - **to** - `{Object}` - CSS properties & values at end of animation. Must have matching `from`
779
- *
780
- * @return {Runner} the animation runner
781
- */
782
- setClass(element, add, remove, options) {
783
- options = prepareAnimateOptions(options);
784
- options.addClass = mergeClasses(options.addClass, add);
785
- options.removeClass = mergeClasses(options.removeClass, remove);
786
- return $$animateQueue.push(element, "setClass", options);
787
- },
788
-
789
- /**
790
- * @ngdoc method
791
- * @name $animate#animate
792
- * @kind function
793
- *
794
- * @description Performs an inline animation on the element which applies the provided to and from CSS styles to the element.
795
- * If any detected CSS transition, keyframe or JavaScript matches the provided className value, then the animation will take
796
- * on the provided styles. For example, if a transition animation is set for the given className, then the provided `from` and
797
- * `to` styles will be applied alongside the given transition. If the CSS style provided in `from` does not have a corresponding
798
- * style in `to`, the style in `from` is applied immediately, and no animation is run.
799
- * If a JavaScript animation is detected then the provided styles will be given in as function parameters into the `animate`
800
- * method (or as part of the `options` parameter):
801
- *
802
- * ```js
803
- * ngModule.animation('.my-inline-animation', function() {
804
- * return {
805
- * animate : function(element, from, to, done, options) {
806
- * //animation
807
- * done();
808
- * }
809
- * }
810
- * });
811
- * ```
812
- *
813
- * @param {Element} element the element which the CSS styles will be applied to
814
- * @param {object} from the from (starting) CSS styles that will be applied to the element and across the animation.
815
- * @param {object} to the to (destination) CSS styles that will be applied to the element and across the animation.
816
- * @param {string=} className an optional CSS class that will be applied to the element for the duration of the animation. If
817
- * this value is left as empty then a CSS class of `ng-inline-animate` will be applied to the element.
818
- * (Note that if no animation is detected then this value will not be applied to the element.)
819
- * @param {object=} options an optional collection of options/styles that will be applied to the element.
820
- * The object can have the following properties:
821
- *
822
- * - **addClass** - `{string}` - space-separated CSS classes to add to element
823
- * - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
824
- * - **removeClass** - `{string}` - space-separated CSS classes to remove from element
825
- * - **to** - `{Object}` - CSS properties & values at end of animation. Must have matching `from`
826
- *
827
- * @return {Runner} the animation runner
828
- */
829
- animate(element, from, to, className, options) {
830
- options = prepareAnimateOptions(options);
831
- options.from = options.from ? extend(options.from, from) : from;
832
- options.to = options.to ? extend(options.to, to) : to;
833
-
834
- className = className || "ng-inline-animate";
835
- options.tempClasses = mergeClasses(options.tempClasses, className);
836
- return $$animateQueue.push(element, "animate", options);
837
- },
838
- };
839
- },
840
- ];
841
- },
842
- ];
579
+ cancel(runner) {
580
+ if (runner.cancel) {
581
+ runner.cancel();
582
+ }
583
+ },
584
+
585
+ /**
586
+ *
587
+ * @ngdoc method
588
+ * @name $animate#enter
589
+ * @kind function
590
+ * @description Inserts the element into the DOM either after the `after` element (if provided) or
591
+ * as the first child within the `parent` element and then triggers an animation.
592
+ * A promise is returned that will be resolved during the next digest once the animation
593
+ * has completed.
594
+ *
595
+ * @param {Element} element the element which will be inserted into the DOM
596
+ * @param {Element} parent the parent element which will append the element as
597
+ * a child (so long as the after element is not present)
598
+ * @param {Element=} after the sibling element after which the element will be appended
599
+ * @param {object=} options an optional collection of options/styles that will be applied to the element.
600
+ * The object can have the following properties:
601
+ *
602
+ * - **addClass** - `{string}` - space-separated CSS classes to add to element
603
+ * - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
604
+ * - **removeClass** - `{string}` - space-separated CSS classes to remove from element
605
+ * - **to** - `{Object}` - CSS properties & values at end of animation. Must have matching `from`
606
+ *
607
+ * @return {Runner} the animation runner
608
+ */
609
+ enter(element, parent, after, options) {
610
+ parent = parent && JQLite(parent);
611
+ after = after && JQLite(after);
612
+ parent = parent || after.parent();
613
+ domInsert(element, parent, after);
614
+ return $$animateQueue.push(
615
+ element,
616
+ "enter",
617
+ prepareAnimateOptions(options),
618
+ );
619
+ },
620
+
621
+ /**
622
+ *
623
+ * @ngdoc method
624
+ * @name $animate#move
625
+ * @kind function
626
+ * @description Inserts (moves) the element into its new position in the DOM either after
627
+ * the `after` element (if provided) or as the first child within the `parent` element
628
+ * and then triggers an animation. A promise is returned that will be resolved
629
+ * during the next digest once the animation has completed.
630
+ *
631
+ * @param {Element} element the element which will be moved into the new DOM position
632
+ * @param {Element} parent the parent element which will append the element as
633
+ * a child (so long as the after element is not present)
634
+ * @param {Element=} after the sibling element after which the element will be appended
635
+ * @param {object=} options an optional collection of options/styles that will be applied to the element.
636
+ * The object can have the following properties:
637
+ *
638
+ * - **addClass** - `{string}` - space-separated CSS classes to add to element
639
+ * - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
640
+ * - **removeClass** - `{string}` - space-separated CSS classes to remove from element
641
+ * - **to** - `{Object}` - CSS properties & values at end of animation. Must have matching `from`
642
+ *
643
+ * @return {Runner} the animation runner
644
+ */
645
+ move(element, parent, after, options) {
646
+ parent = parent && JQLite(parent);
647
+ after = after && JQLite(after);
648
+ parent = parent || after.parent();
649
+ domInsert(element, parent, after);
650
+ return $$animateQueue.push(
651
+ element,
652
+ "move",
653
+ prepareAnimateOptions(options),
654
+ );
655
+ },
656
+
657
+ /**
658
+ * @ngdoc method
659
+ * @name $animate#leave
660
+ * @kind function
661
+ * @description Triggers an animation and then removes the element from the DOM.
662
+ * When the function is called a promise is returned that will be resolved during the next
663
+ * digest once the animation has completed.
664
+ *
665
+ * @param {Element} element the element which will be removed from the DOM
666
+ * @param {object=} options an optional collection of options/styles that will be applied to the element.
667
+ * The object can have the following properties:
668
+ *
669
+ * - **addClass** - `{string}` - space-separated CSS classes to add to element
670
+ * - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
671
+ * - **removeClass** - `{string}` - space-separated CSS classes to remove from element
672
+ * - **to** - `{Object}` - CSS properties & values at end of animation. Must have matching `from`
673
+ *
674
+ * @return {Runner} the animation runner
675
+ */
676
+ leave(element, options) {
677
+ return $$animateQueue.push(
678
+ element,
679
+ "leave",
680
+ prepareAnimateOptions(options),
681
+ () => {
682
+ element.remove();
683
+ },
684
+ );
685
+ },
686
+
687
+ /**
688
+ * @ngdoc method
689
+ * @name $animate#addClass
690
+ * @kind function
691
+ *
692
+ * @description Triggers an addClass animation surrounding the addition of the provided CSS class(es). Upon
693
+ * execution, the addClass operation will only be handled after the next digest and it will not trigger an
694
+ * animation if element already contains the CSS class or if the class is removed at a later step.
695
+ * Note that class-based animations are treated differently compared to structural animations
696
+ * (like enter, move and leave) since the CSS classes may be added/removed at different points
697
+ * depending if CSS or JavaScript animations are used.
698
+ *
699
+ * @param {Element} element the element which the CSS classes will be applied to
700
+ * @param {string} className the CSS class(es) that will be added (multiple classes are separated via spaces)
701
+ * @param {object=} options an optional collection of options/styles that will be applied to the element.
702
+ * The object can have the following properties:
703
+ *
704
+ * - **removeClass** - `{string}` - space-separated CSS classes to remove from element
705
+ * - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
706
+ * - **to** - `{Object}` - CSS properties & values at end of animation. Must have matching `from`
707
+ *
708
+ * @return {Runner} animationRunner the animation runner
709
+ */
710
+ addClass(element, className, options) {
711
+ options = prepareAnimateOptions(options);
712
+ options.addClass = mergeClasses(options.addclass, className);
713
+ return $$animateQueue.push(element, "addClass", options);
714
+ },
715
+
716
+ /**
717
+ * @ngdoc method
718
+ * @name $animate#removeClass
719
+ * @kind function
720
+ *
721
+ * @description Triggers a removeClass animation surrounding the removal of the provided CSS class(es). Upon
722
+ * execution, the removeClass operation will only be handled after the next digest and it will not trigger an
723
+ * animation if element does not contain the CSS class or if the class is added at a later step.
724
+ * Note that class-based animations are treated differently compared to structural animations
725
+ * (like enter, move and leave) since the CSS classes may be added/removed at different points
726
+ * depending if CSS or JavaScript animations are used.
727
+ *
728
+ * @param {Element} element the element which the CSS classes will be applied to
729
+ * @param {string} className the CSS class(es) that will be removed (multiple classes are separated via spaces)
730
+ * @param {object=} options an optional collection of options/styles that will be applied to the element.
731
+ * The object can have the following properties:
732
+ *
733
+ * - **addClass** - `{string}` - space-separated CSS classes to add to element
734
+ * - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
735
+ * - **to** - `{Object}` - CSS properties & values at end of animation. Must have matching `from`
736
+ *
737
+ * @return {Runner} the animation runner
738
+ */
739
+ removeClass(element, className, options) {
740
+ options = prepareAnimateOptions(options);
741
+ options.removeClass = mergeClasses(options.removeClass, className);
742
+ return $$animateQueue.push(element, "removeClass", options);
743
+ },
744
+
745
+ /**
746
+ * @ngdoc method
747
+ * @name $animate#setClass
748
+ * @kind function
749
+ *
750
+ * @description Performs both the addition and removal of a CSS classes on an element and (during the process)
751
+ * triggers an animation surrounding the class addition/removal. Much like `$animate.addClass` and
752
+ * `$animate.removeClass`, `setClass` will only evaluate the classes being added/removed once a digest has
753
+ * passed. Note that class-based animations are treated differently compared to structural animations
754
+ * (like enter, move and leave) since the CSS classes may be added/removed at different points
755
+ * depending if CSS or JavaScript animations are used.
756
+ *
757
+ * @param {Element} element the element which the CSS classes will be applied to
758
+ * @param {string} add the CSS class(es) that will be added (multiple classes are separated via spaces)
759
+ * @param {string} remove the CSS class(es) that will be removed (multiple classes are separated via spaces)
760
+ * @param {object=} options an optional collection of options/styles that will be applied to the element.
761
+ * The object can have the following properties:
762
+ *
763
+ * - **addClass** - `{string}` - space-separated CSS classes to add to element
764
+ * - **removeClass** - `{string}` - space-separated CSS classes to remove from element
765
+ * - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
766
+ * - **to** - `{Object}` - CSS properties & values at end of animation. Must have matching `from`
767
+ *
768
+ * @return {Runner} the animation runner
769
+ */
770
+ setClass(element, add, remove, options) {
771
+ options = prepareAnimateOptions(options);
772
+ options.addClass = mergeClasses(options.addClass, add);
773
+ options.removeClass = mergeClasses(options.removeClass, remove);
774
+ return $$animateQueue.push(element, "setClass", options);
775
+ },
776
+
777
+ /**
778
+ * @ngdoc method
779
+ * @name $animate#animate
780
+ * @kind function
781
+ *
782
+ * @description Performs an inline animation on the element which applies the provided to and from CSS styles to the element.
783
+ * If any detected CSS transition, keyframe or JavaScript matches the provided className value, then the animation will take
784
+ * on the provided styles. For example, if a transition animation is set for the given className, then the provided `from` and
785
+ * `to` styles will be applied alongside the given transition. If the CSS style provided in `from` does not have a corresponding
786
+ * style in `to`, the style in `from` is applied immediately, and no animation is run.
787
+ * If a JavaScript animation is detected then the provided styles will be given in as function parameters into the `animate`
788
+ * method (or as part of the `options` parameter):
789
+ *
790
+ * ```js
791
+ * ngModule.animation('.my-inline-animation', function() {
792
+ * return {
793
+ * animate : function(element, from, to, done, options) {
794
+ * //animation
795
+ * done();
796
+ * }
797
+ * }
798
+ * });
799
+ * ```
800
+ *
801
+ * @param {Element} element the element which the CSS styles will be applied to
802
+ * @param {object} from the from (starting) CSS styles that will be applied to the element and across the animation.
803
+ * @param {object} to the to (destination) CSS styles that will be applied to the element and across the animation.
804
+ * @param {string=} className an optional CSS class that will be applied to the element for the duration of the animation. If
805
+ * this value is left as empty then a CSS class of `ng-inline-animate` will be applied to the element.
806
+ * (Note that if no animation is detected then this value will not be applied to the element.)
807
+ * @param {object=} options an optional collection of options/styles that will be applied to the element.
808
+ * The object can have the following properties:
809
+ *
810
+ * - **addClass** - `{string}` - space-separated CSS classes to add to element
811
+ * - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
812
+ * - **removeClass** - `{string}` - space-separated CSS classes to remove from element
813
+ * - **to** - `{Object}` - CSS properties & values at end of animation. Must have matching `from`
814
+ *
815
+ * @return {Runner} the animation runner
816
+ */
817
+ animate(element, from, to, className, options) {
818
+ options = prepareAnimateOptions(options);
819
+ options.from = options.from ? extend(options.from, from) : from;
820
+ options.to = options.to ? extend(options.to, to) : to;
821
+
822
+ className = className || "ng-inline-animate";
823
+ options.tempClasses = mergeClasses(options.tempClasses, className);
824
+ return $$animateQueue.push(element, "animate", options);
825
+ },
826
+ };
827
+ },
828
+ ];
829
+ }