File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -25,8 +25,10 @@ export class Timeline {
2525 this . _onceOnly = ! ! timelineData . onceOnly
2626 this . _actionStarts = { }
2727
28- // Used to track if the timeline is played per each trigger.
29- this . timelineData . _playedTriggers = new WeakSet ( )
28+ // Only track played triggers if onceOnly is enabled.
29+ if ( this . _onceOnly && ! this . timelineData . _playedTriggers ) {
30+ this . timelineData . _playedTriggers = new Set ( )
31+ }
3032 }
3133
3234 this . _targets = [ ]
@@ -44,14 +46,13 @@ export class Timeline {
4446 createInstance ( options ) {
4547 // If triggered only once, then we don't create anymore animations.
4648 const currentTrigger = this . interaction . getCurrentTrigger ( )
47- if ( this . getRunner ( ) . isFrontend ) {
48- if ( this . timelineData . onceOnly && this . timelineData . _playedTriggers . has ( currentTrigger ) ) {
49+ if ( this . getRunner ( ) . isFrontend && currentTrigger && this . _onceOnly ) {
50+ if ( this . timelineData . _playedTriggers . has ( currentTrigger ) ) {
4951 return null
5052 }
53+ this . timelineData . _playedTriggers . add ( currentTrigger )
5154 }
5255
53- this . timelineData . _playedTriggers . add ( currentTrigger )
54-
5556 // We have to empty the promises here because we are creating a new timeline.
5657 // This is to prevent the promises from the previous timeline from affecting the new one.
5758 this . _funcPromises = { }
You can’t perform that action at this time.
0 commit comments