|
| 1 | +/** |
| 2 | + * The [animate] library makes it easier to build animations that affect the |
| 3 | + * lifecycle of dom elements. The cononical example of this is animating the |
| 4 | + * removal of an element from the dom. In order to do this, |
| 5 | + * one must know about the duration of the animation, and immediatly perform |
| 6 | + * changes in the backing data model. The animation library uses computed css |
| 7 | + * styles to calculate the total duration of animation and handles the addition |
| 8 | + * and removal of elements for the dom for elements that are manipulated by |
| 9 | + * block level directives such as `ng-if`, `ng-repeat`, `ng-hide`, and more. |
| 10 | + * |
| 11 | + * To use, install the NgAnimateModule into your main module: |
| 12 | + * |
| 13 | + * var module = new Module() |
| 14 | + * ..install(new NgAnimateModule()); |
| 15 | + * |
| 16 | + * Once this is installed, all block level dom manipulations will be routed |
| 17 | + * through the [CssAnimate] implementation instead of the default [NgAnimate] |
| 18 | + * class. |
| 19 | + * |
| 20 | + * For dom manipulations, this will add the `.ng-enter` class to a new dom |
| 21 | + * element, and then read the computed style. If there is a transition or |
| 22 | + * keyframe animation, the animation duration will be read, |
| 23 | + * and the animation will be performed. The `.ng-enter-active` class will be |
| 24 | + * added to set the target state for transition based animations. For |
| 25 | + * removing elements from the dom, a simliar pattern is followed. The |
| 26 | + * `.ng-leave` class will be added to an element, the transition and / or |
| 27 | + * keyframe animation duration will be computed, and if it is non-zero the |
| 28 | + * animation will be run by adding the `.ng-leave-active` class, |
| 29 | + * and the element will be physically removed after the animation completes. |
| 30 | + * |
| 31 | + * The same set of steps is run for each of the following types of dom |
| 32 | + * manipulation: |
| 33 | + * |
| 34 | + * * `.ng-enter` |
| 35 | + * * `.ng-leave` |
| 36 | + * * `.ng-move` |
| 37 | + * * `.{cssclass}-add` |
| 38 | + * * `.{cssclasss}-remove` |
| 39 | + * |
| 40 | + * When writing the css for animating a component you should avoid putting |
| 41 | + * css transitions on elements that might be animated, otherwise there may be |
| 42 | + * unintended pauses or side effects when an element is removed. |
| 43 | + * |
| 44 | + * Fade out example: |
| 45 | + * |
| 46 | + * HTML: |
| 47 | + * <div class="goodby" ng-if="ctrl.visible"> |
| 48 | + * Goodby world! |
| 49 | + * </div> |
| 50 | + * |
| 51 | + * CSS: |
| 52 | + * .goodby.ng-leave { |
| 53 | + * opacity: 1; |
| 54 | + * transition: opacity 1s; |
| 55 | + * } |
| 56 | + * .goodby.ng-leave.ng-leave-active { |
| 57 | + * opacity: 0; |
| 58 | + * } |
| 59 | + * |
| 60 | + * This will perform a fade out animation on the 'goodby' div when the |
| 61 | + * `ctrl.visible` property goes from `true` to `false`. |
| 62 | + * |
| 63 | + * The [CssAnimate] will also do optimizations on running animations by |
| 64 | + * preventing child dom animations with the [AnimationOptimizer]. This |
| 65 | + * prevents transitions on child elements while the parent is animating, |
| 66 | + * but will not stop running transitions once they have started. |
| 67 | + * |
| 68 | + * Finally, it's possible to change the behavior of the [AnimationOptimizer] |
| 69 | + * by using the `ng-animate` and `ng-animate-children` with the options |
| 70 | + * `never`, `always`, or `auto`. `ng-animate` works only on the specific |
| 71 | + * element it is applied too and will override other optimizations if `never` |
| 72 | + * or `always` is specified. `ng-animate` defaults to `auto` which will |
| 73 | + * defer to the `ng-animate-children` on a parent element or the currently |
| 74 | + * running animation check. |
| 75 | + * |
| 76 | + * `ng-animate-children` allows animation to be controlled on large chunks of |
| 77 | + * dom. It only affects child elements, and allows the `always`, `never`, |
| 78 | + * and `auto` values to be specified. Always will always attempt animations |
| 79 | + * on child dom directives, never will always prevent them (except in the |
| 80 | + * case where a given element has `ng-animate="always"` specified), |
| 81 | + * and `auto` will defer the decision to the currently running animation |
| 82 | + * check. |
| 83 | + */ |
| 84 | + |
1 | 85 | library angular.animate;
|
2 | 86 |
|
3 | 87 | import 'dart:async';
|
|
0 commit comments