From f39f155ee2c1a13f498186367b35dcd8d8dcc6e9 Mon Sep 17 00:00:00 2001 From: Alquen Sarmiento Date: Thu, 15 Jan 2026 14:48:43 +0800 Subject: [PATCH 1/2] fix: handle when no valid trigger is returned --- src/frontend/scripts/class-timeline.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/frontend/scripts/class-timeline.js b/src/frontend/scripts/class-timeline.js index da5152e..2a2266c 100644 --- a/src/frontend/scripts/class-timeline.js +++ b/src/frontend/scripts/class-timeline.js @@ -25,8 +25,10 @@ export class Timeline { this._onceOnly = !! timelineData.onceOnly this._actionStarts = {} - // Used to track if the timeline is played per each trigger. - this.timelineData._playedTriggers = new WeakSet() + // Only track played triggers if onceOnly is enabled. + if ( this._onceOnly && ! this.timelineData._playedTriggers ) { + this.timelineData._playedTriggers = new Set() + } } this._targets = [] @@ -44,14 +46,13 @@ export class Timeline { createInstance( options ) { // If triggered only once, then we don't create anymore animations. const currentTrigger = this.interaction.getCurrentTrigger() - if ( this.getRunner().isFrontend ) { - if ( this.timelineData.onceOnly && this.timelineData._playedTriggers.has( currentTrigger ) ) { + if ( this.getRunner().isFrontend && currentTrigger && this.timelineData.onceOnly ) { + if ( this.timelineData._playedTriggers.has( currentTrigger ) ) { return null } + this.timelineData._playedTriggers.add( currentTrigger ) } - this.timelineData._playedTriggers.add( currentTrigger ) - // We have to empty the promises here because we are creating a new timeline. // This is to prevent the promises from the previous timeline from affecting the new one. this._funcPromises = {} From 470f93d4fe32566e6bfe9bb236c9c4d0a869eef5 Mon Sep 17 00:00:00 2001 From: Alquen Sarmiento Date: Thu, 15 Jan 2026 14:52:50 +0800 Subject: [PATCH 2/2] fix: use this._onceOnly --- src/frontend/scripts/class-timeline.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/scripts/class-timeline.js b/src/frontend/scripts/class-timeline.js index 2a2266c..c99960c 100644 --- a/src/frontend/scripts/class-timeline.js +++ b/src/frontend/scripts/class-timeline.js @@ -46,7 +46,7 @@ export class Timeline { createInstance( options ) { // If triggered only once, then we don't create anymore animations. const currentTrigger = this.interaction.getCurrentTrigger() - if ( this.getRunner().isFrontend && currentTrigger && this.timelineData.onceOnly ) { + if ( this.getRunner().isFrontend && currentTrigger && this._onceOnly ) { if ( this.timelineData._playedTriggers.has( currentTrigger ) ) { return null }