diff --git a/tns-core-modules/ui/animation/keyframe-animation.ts b/tns-core-modules/ui/animation/keyframe-animation.ts index 6bf493f9e..be57131a0 100644 --- a/tns-core-modules/ui/animation/keyframe-animation.ts +++ b/tns-core-modules/ui/animation/keyframe-animation.ts @@ -74,7 +74,6 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition { public iterations: number = 1; private _resolve; - private _reject; private _isPlaying: boolean; private _isForwards: boolean; private _nativeAnimations: Array; @@ -161,21 +160,19 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition { let animation = this._nativeAnimations[0]; this._resetAnimationValues(this._target, animation); } - this._rejectAnimationFinishedPromise(); + this._resetAnimations(); } public play(view: View): Promise { if (this._isPlaying) { - const reason = "Keyframe animation is already playing."; - traceWrite(reason, traceCategories.Animation, traceType.warn); - return new Promise((resolve, reject) => { - reject(reason); + traceWrite("Keyframe animation is already playing.", traceCategories.Animation, traceType.warn); + return new Promise(resolve => { + resolve(); }); } - let animationFinishedPromise = new Promise((resolve, reject) => { + let animationFinishedPromise = new Promise(resolve => { this._resolve = resolve; - this._reject = reject; }); this._isPlaying = true; @@ -239,10 +236,10 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition { // Catch the animation cancel to prevent unhandled promise rejection warnings animation.play().then(() => { this.animate(view, index + 1, iterations); + }, (error: any) => { + traceWrite(typeof error === "string" ? error : error.message, traceCategories.Animation, traceType.warn); }).catch((error: any) => { - if (error.message.indexOf("Animation cancelled") < 0) { - throw error; - } + traceWrite(typeof error === "string" ? error : error.message, traceCategories.Animation, traceType.warn); }); // tslint:disable-line this._nativeAnimations.push(animation); } @@ -255,11 +252,10 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition { this._resolve(); } - public _rejectAnimationFinishedPromise() { + public _resetAnimations() { this._nativeAnimations = new Array(); this._isPlaying = false; this._target = null; - this._reject(new Error("Animation cancelled.")); } private _resetAnimationValues(view: View, animation: Object) {