File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,6 +24,9 @@ export class Timeline {
2424 this . _resetAtStart = ! ! timelineData . reset
2525 this . _onceOnly = ! ! timelineData . onceOnly
2626 this . _actionStarts = { }
27+
28+ // Used to track if the timeline is played per each trigger.
29+ this . timelineData . _playedTriggers = new WeakSet ( )
2730 }
2831
2932 this . _targets = [ ]
@@ -40,19 +43,19 @@ export class Timeline {
4043
4144 createInstance ( options ) {
4245 // If triggered only once, then we don't create anymore animations.
43- // We reference timelineData._played here so that it persists across other timeline instances.
46+ const currentTrigger = this . interaction . getCurrentTrigger ( )
4447 if ( this . getRunner ( ) . isFrontend ) {
45- if ( this . timelineData . onceOnly && this . timelineData . _played ) {
48+ if ( this . timelineData . onceOnly && this . timelineData . _playedTriggers . has ( currentTrigger ) ) {
4649 return null
4750 }
4851 }
4952
53+ this . timelineData . _playedTriggers . add ( currentTrigger )
54+
5055 // We have to empty the promises here because we are creating a new timeline.
5156 // This is to prevent the promises from the previous timeline from affecting the new one.
5257 this . _funcPromises = { }
5358
54- this . timelineData . _played = true
55-
5659 const propsToPass = { }
5760 if ( this . type === 'percentage' ) {
5861 propsToPass . duration = 100 // 100% so it's easier to compute the actions later.
You can’t perform that action at this time.
0 commit comments