|
39 | 39 | * return {
|
40 | 40 | * enter: function(element, doneFn) {
|
41 | 41 | * var height = element[0].offsetHeight;
|
42 |
| - * var animation = $animateCss(element, { |
| 42 | + * var animator = $animateCss(element, { |
43 | 43 | * from: { height:'0px' },
|
44 | 44 | * to: { height:height + 'px' },
|
45 | 45 | * duration: 1 // one second
|
46 | 46 | * });
|
47 |
| - * |
48 |
| - * // if no possible animation can be triggered due |
49 |
| - * // to the combination of options then `animation` |
50 |
| - * // will be returned as undefined |
51 |
| - * animation.start().done(doneFn); |
| 47 | + * animator.start().done(doneFn); |
52 | 48 | * }
|
53 | 49 | * }
|
54 | 50 | * }]);
|
|
71 | 67 | * return {
|
72 | 68 | * enter: function(element, doneFn) {
|
73 | 69 | * var height = element[0].offsetHeight;
|
74 |
| - * var animation = $animateCss(element, { |
| 70 | + * var animator = $animateCss(element, { |
75 | 71 | * addClass: 'red large-text pulse-twice',
|
76 | 72 | * easing: 'ease-out',
|
77 | 73 | * from: { height:'0px' },
|
78 | 74 | * to: { height:height + 'px' },
|
79 | 75 | * duration: 1 // one second
|
80 | 76 | * });
|
81 |
| - * |
82 |
| - * // if no possible animation can be triggered due |
83 |
| - * // to the combination of options then `animation` |
84 |
| - * // will be returned as undefined |
85 |
| - * animation.start().done(doneFn); |
| 77 | + * animator.start().done(doneFn); |
86 | 78 | * }
|
87 | 79 | * }
|
88 | 80 | * }]);
|
|
122 | 114 | * styles using the `from` and `to` properties.
|
123 | 115 | *
|
124 | 116 | * ```js
|
125 |
| - * var animation = $animateCss(element, { |
| 117 | + * var animator = $animateCss(element, { |
126 | 118 | * from: { background:'red' },
|
127 | 119 | * to: { background:'blue' }
|
128 | 120 | * });
|
| 121 | + * animator.start(); |
129 | 122 | * ```
|
130 | 123 | *
|
131 | 124 | * ```css
|
|
158 | 151 | * added and removed on the element). Once `$animateCss` is called it will return an object with the following properties:
|
159 | 152 | *
|
160 | 153 | * ```js
|
161 |
| - * var animation = $animateCss(element, { ... }); |
| 154 | + * var animator = $animateCss(element, { ... }); |
162 | 155 | * ```
|
163 | 156 | *
|
164 |
| - * Now what do the contents of our `animation` variable look like: |
| 157 | + * Now what do the contents of our `animator` variable look like: |
165 | 158 | *
|
166 | 159 | * ```js
|
167 | 160 | * {
|
|
185 | 178 | * The example below should put this into perspective:
|
186 | 179 | *
|
187 | 180 | * ```js
|
188 |
| - * var animation = $animateCss(element, { ... }); |
189 |
| - * |
190 |
| - * // remember that if there is no CSS animation detected on the element |
191 |
| - * // then the value returned from $animateCss will be null |
192 |
| - * if (animation) { |
193 |
| - * animation.start().done(function() { |
194 |
| - * // yaay the animation is over |
195 |
| - * doneCallback(); |
196 |
| - * }); |
197 |
| - * } else { |
| 181 | + * var animator = $animateCss(element, { ... }); |
| 182 | + * animator.start().done(function() { |
| 183 | + * // yaay the animation is over |
198 | 184 | * doneCallback();
|
199 |
| - * } |
| 185 | + * }); |
200 | 186 | * ```
|
201 | 187 | *
|
202 | 188 | * @param {DOMElement} element the element that will be animated
|
|
223 | 209 | * `stagger` option value of `0.1` is used then there will be a stagger delay of `600ms`)
|
224 | 210 | * `applyClassesEarly` - Whether or not the classes being added or removed will be used when detecting the animation. This is set by `$animate` when enter/leave/move animations are fired to ensure that the CSS classes are resolved in time. (Note that this will prevent any transitions from occuring on the classes being added and removed.)
|
225 | 211 | *
|
226 |
| - * @return {null|object} an object with a start method and details about the animation. If no animation is detected then a value of `null` will be returned. |
| 212 | + * @return {object} an object with start and end methods and details about the animation. |
227 | 213 | *
|
228 | 214 | * * `start` - The method to start the animation. This will return a `Promise` when called.
|
229 | 215 | * * `end` - This method will cancel the animation and remove all applied CSS classes and styles.
|
@@ -538,8 +524,7 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
|
538 | 524 | var maxDurationTime;
|
539 | 525 |
|
540 | 526 | if (options.duration === 0 || (!$sniffer.animations && !$sniffer.transitions)) {
|
541 |
| - close(); |
542 |
| - return; |
| 527 | + return closeAndReturnNoopAnimator(); |
543 | 528 | }
|
544 | 529 |
|
545 | 530 | var method = options.event && isArray(options.event)
|
@@ -586,8 +571,7 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
|
586 | 571 | // there is no way we can trigger an animation since no styles and
|
587 | 572 | // no classes are being applied which would then trigger a transition
|
588 | 573 | if (!hasToStyles && !setupClasses) {
|
589 |
| - close(); |
590 |
| - return false; |
| 574 | + return closeAndReturnNoopAnimator(); |
591 | 575 | }
|
592 | 576 |
|
593 | 577 | var cacheKey, stagger;
|
@@ -682,8 +666,7 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
|
682 | 666 | }
|
683 | 667 |
|
684 | 668 | if (maxDuration === 0 && !flags.recalculateTimingStyles) {
|
685 |
| - close(); |
686 |
| - return false; |
| 669 | + return closeAndReturnNoopAnimator(); |
687 | 670 | }
|
688 | 671 |
|
689 | 672 | // we need to recalculate the delay value since we used a pre-emptive negative
|
@@ -711,6 +694,7 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
|
711 | 694 |
|
712 | 695 | // TODO(matsko): for 1.5 change this code to have an animator object for better debugging
|
713 | 696 | return {
|
| 697 | + $$willAnimate: true, |
714 | 698 | end: endFn,
|
715 | 699 | start: function() {
|
716 | 700 | if (animationClosed) return;
|
@@ -790,6 +774,23 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
|
790 | 774 | }
|
791 | 775 | }
|
792 | 776 |
|
| 777 | + function closeAndReturnNoopAnimator() { |
| 778 | + runner = new $$AnimateRunner({ |
| 779 | + end: endFn, |
| 780 | + cancel: cancelFn |
| 781 | + }); |
| 782 | + |
| 783 | + close(); |
| 784 | + |
| 785 | + return { |
| 786 | + $$willAnimate: false, |
| 787 | + start: function() { |
| 788 | + return runner; |
| 789 | + }, |
| 790 | + end: endFn |
| 791 | + }; |
| 792 | + } |
| 793 | + |
793 | 794 | function start() {
|
794 | 795 | if (animationClosed) return;
|
795 | 796 |
|
|
0 commit comments