From 107f5ca5e64c5ebd8d14d6cb6ea8f94feee9bb17 Mon Sep 17 00:00:00 2001 From: Davide Tantillo Date: Thu, 28 Mar 2024 10:13:49 +0100 Subject: [PATCH] [ts] Port of commit 88b009c: AnimationState, improved triggering complete event. --- spine-ts/spine-core/src/AnimationState.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/spine-ts/spine-core/src/AnimationState.ts b/spine-ts/spine-core/src/AnimationState.ts index 6ad716c6c..dc53d373e 100644 --- a/spine-ts/spine-core/src/AnimationState.ts +++ b/spine-ts/spine-core/src/AnimationState.ts @@ -436,9 +436,14 @@ export class AnimationState { // Queue complete if completed a loop iteration or the animation. let complete = false; - if (entry.loop) - complete = duration == 0 || trackLastWrapped > entry.trackTime % duration; - else + if (entry.loop) { + if (duration == 0) + complete = true; + else { + const cycles = Math.floor(entry.trackTime / duration); + complete = cycles > 0 && cycles > Math.floor(entry.trackTime / duration); + } + } else complete = animationTime >= animationEnd && entry.animationLast < animationEnd; if (complete) this.queue.complete(entry);