GSAP
GSAP copied to clipboard
Issue with setting timeline progress to 0
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);