@angular-wave/angular.ts 0.0.51 → 0.0.52

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