|
2 | 2 | import { AnimationDefinition } from "."; |
3 | 3 | import { View } from "../core/view"; |
4 | 4 |
|
5 | | -import { AnimationBase, Properties, PropertyAnimation, CubicBezierAnimationCurve, AnimationPromise, Color, traceWrite, traceEnabled, traceCategories } from "./animation-common"; |
| 5 | +import { AnimationBase, Properties, PropertyAnimation, CubicBezierAnimationCurve, AnimationPromise, Color, traceWrite, traceEnabled, traceCategories, traceType } from "./animation-common"; |
6 | 6 | import { |
7 | 7 | opacityProperty, backgroundColorProperty, rotateProperty, |
8 | 8 | translateXProperty, translateYProperty, scaleXProperty, scaleYProperty |
@@ -135,6 +135,10 @@ export class Animation extends AnimationBase { |
135 | 135 | } |
136 | 136 |
|
137 | 137 | public play(): AnimationPromise { |
| 138 | + if (this.isPlaying) { |
| 139 | + return this._rejectAlreadyPlaying(); |
| 140 | + } |
| 141 | + |
138 | 142 | let animationFinishedPromise = super.play(); |
139 | 143 |
|
140 | 144 | this._animators = new Array<android.animation.Animator>(); |
@@ -170,10 +174,13 @@ export class Animation extends AnimationBase { |
170 | 174 | } |
171 | 175 |
|
172 | 176 | public cancel(): void { |
173 | | - super.cancel(); |
174 | | - if (traceEnabled()) { |
175 | | - traceWrite("Cancelling AnimatorSet.", traceCategories.Animation); |
| 177 | + if (!this.isPlaying) { |
| 178 | + traceWrite("Animation is not currently playing.", traceCategories.Animation, traceType.warn); |
| 179 | + return; |
176 | 180 | } |
| 181 | + |
| 182 | + traceWrite("Cancelling AnimatorSet.", traceCategories.Animation); |
| 183 | + |
177 | 184 | this._animatorSet.cancel(); |
178 | 185 | } |
179 | 186 |
|
@@ -301,7 +308,7 @@ export class Animation extends AnimationBase { |
301 | 308 | } else { |
302 | 309 | propertyAnimation.target.style[backgroundColorProperty.keyframe] = originalValue1; |
303 | 310 | } |
304 | | - |
| 311 | + |
305 | 312 | if (propertyAnimation.target.nativeViewProtected && propertyAnimation.target[backgroundColorProperty.setNative]) { |
306 | 313 | propertyAnimation.target[backgroundColorProperty.setNative](propertyAnimation.target.style.backgroundColor); |
307 | 314 | } |
@@ -414,7 +421,7 @@ export class Animation extends AnimationBase { |
414 | 421 | } else { |
415 | 422 | propertyAnimation.target.style[rotateProperty.keyframe] = originalValue1; |
416 | 423 | } |
417 | | - |
| 424 | + |
418 | 425 | if (propertyAnimation.target.nativeViewProtected) { |
419 | 426 | propertyAnimation.target[rotateProperty.setNative](propertyAnimation.target.style.rotate); |
420 | 427 | } |
|
0 commit comments