Rebuild and stop timeline

When I trigger a button, I want the timeline animations to stop/pause and reset to their starting state.

Currently, pressing the button successfully rebuilds the timeline (this part works), but instead of resetting to the start, the animated objects remain in whatever state they were in at the moment I triggered the button.

How can I make it so that, when I press the button, the timeline resets and the animated objects return to their initial state at the start of the timeline?

image

Hello,
To achieve a complete reset of the timeline and return all animated objects to their initial states when the button is pressed, you can use the following approach (assuming you’re working with a JavaScript animation library like GSAP or similar):

Pause and Reset the Timeline: Use .pause(0) to pause the timeline at the beginning (0 seconds) immediately. This will both pause and reset the timeline to the starting position in one step.

Clear and Rebuild the Timeline: If needed, you can clear or rebuild the timeline to ensure that it restarts from scratch. This may be helpful if the timeline has complex animations that need to be rebuilt each time. E-hallpass Securly

document.getElementById(“yourButton”).addEventListener(“click”, resetTimeline);
Explanation:
timeline.pause(0); resets the timeline to the starting position (0 seconds) and pauses it there.
This approach should work even if your timeline is dynamically rebuilt on each button click since it effectively reinitializes the timeline state.
Best Regards
merry867