Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with setting timeline progress to 0 #597

Open
Antonzo opened this issue Oct 1, 2024 · 0 comments
Open

Issue with setting timeline progress to 0 #597

Antonzo opened this issue Oct 1, 2024 · 0 comments

Comments

@Antonzo
Copy link

Antonzo commented Oct 1, 2024

Code: https://codepen.io/Antonzo/pen/NWQxrYe

Issue:
After the timeline reaches 2 (or more) loops in play mode and the progress is set to 0 afterwards, it is automatically set to 1 right after.

Timeline setup:

const tl = new gsap.core.Timeline({
  repeat: -1,
  paused: true,
  endTime: 1,
  duration: 1,
  onUpdate: () => {
    console.log("onUpdate: ", tl.time());
  }
});

Execution flow:
tl.play();
await new Promise((resolve) => setTimeout(resolve, 1500));
tl.pause();
tl.progress(0);

Last 5 console outputs:
"onUpdate: " 0.469
"onUpdate: " 0.485
"onUpdate: " 0.502
"onUpdate: " 0
"onUpdate: " 1

As you, then last one is triggered to set progress to the end.

Workaround:

tl.totalProgress(0);
tl.progress(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant