Fix unhandled rejection warnings in keyframe animations.

This commit is contained in:
Hristo Deshev
2017-03-23 13:26:56 +02:00
committed by Hristo Deshev
parent b89951845b
commit c4dd3782d5

View File

@@ -212,9 +212,14 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition {
let animationDef = this.animations[index];
(<any>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);
}
}