From 8e6200138945392faaffb65d890eb0d0efcd1417 Mon Sep 17 00:00:00 2001 From: Beau Blyth Date: Mon, 30 Sep 2019 21:56:49 -0700 Subject: [PATCH] looping behaviour mirrored in preview --- app/frame_handler.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/frame_handler.ts b/app/frame_handler.ts index ae705db..34d0089 100644 --- a/app/frame_handler.ts +++ b/app/frame_handler.ts @@ -52,7 +52,14 @@ export class FrameHandler { public AdvanceFrames(amount: number) { this.currentFrame += amount; - this.currentFrame %= this.filenames.length; + if (this.animationData.loop || !this.playingAnimation) { + this.currentFrame %= this.filenames.length; + } else { + if (this.currentFrame > this.filenames.length - 1) { + this.playingAnimation = false; + this.currentFrame = Math.min(this.currentFrame, this.filenames.length - 1); + } + } if (this.currentFrame < 0) { this.currentFrame = this.filenames.length - 1; } @@ -67,6 +74,9 @@ export class FrameHandler { public TogglePlayingAnimation() { this.playingAnimation = !this.playingAnimation; + if (this.playingAnimation && this.currentFrame == this.filenames.length - 1 && !this.animationData.loop) { + this.currentFrame = -1; + } console.log('playingAnimation = ', this.playingAnimation); } public StopPlayingAnimation() {