From c4dd3782d5d0e9b1d9a7aed0929b2cf710c84304 Mon Sep 17 00:00:00 2001 From: Hristo Deshev Date: Thu, 23 Mar 2017 13:26:56 +0200 Subject: [PATCH] Fix unhandled rejection warnings in keyframe animations. --- tns-core-modules/ui/animation/keyframe-animation.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tns-core-modules/ui/animation/keyframe-animation.ts b/tns-core-modules/ui/animation/keyframe-animation.ts index 29800b135..79e0abaa2 100644 --- a/tns-core-modules/ui/animation/keyframe-animation.ts +++ b/tns-core-modules/ui/animation/keyframe-animation.ts @@ -212,9 +212,14 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition { let animationDef = this.animations[index]; (animationDef).target = view; let animation = new Animation([animationDef]); + // Catch the animation cancel to prevent unhandled promise rejection warnings animation.play().then(() => { this.animate(view, index + 1, iterations); - }); + }).catch((error: any) => { + if (error.message.indexOf("Animation cancelled") < 0) { + throw error; + } + }); // tslint:disable-line this._nativeAnimations.push(animation); } }