fix(animations): change throw -> trace to avoid unnecessary app crash (#5475)

* fix(animations): change throw -> trace to avoid unnecessary app crash

Fixes major cause of crashes/bugs in production apps using animation.

* Fix fix animation throw (#1)

* chore(tests): Cleanup code snippets comments

* refactor(animations): Plat-specific cancel and play methods refactored
This commit is contained in:
Nathan Walker
2018-03-08 10:42:33 -08:00
committed by Svetoslav
parent 8141737f74
commit fa80355464
5 changed files with 82 additions and 31 deletions

View File

@@ -54,6 +54,31 @@ export function test_AnimatingProperties(done) {
// << animation-properties
}
export function test_PlayRejectsWhenAlreadyPlayingAnimation(done) {
let label = prepareTest();
var animation = label.createAnimation({ translate: { x: 100, y: 100 }, duration: 5 });
animation.play();
animation.play().then(() => {
// should never get here
throw new Error("Already playing.");
}, (e) => {
TKUnit.assert(animation.isPlaying === true, "animation.isPlaying should be true since it's currently playing.");
if (e === "Animation is already playing.") {
done();
}
});
}
export function test_CancelIgnoredWhenNotPlayingAnimation() {
let label = prepareTest();
var animation = label.createAnimation({ translate: { x: 100, y: 100 }, duration: 5 });
animation.cancel(); // should not throw
TKUnit.assert(!animation.isPlaying, "animation.isPlaying should be falsey since it was never played.");
}
export function test_CancellingAnimation(done) {
let label = prepareTest();