GSAP icon indicating copy to clipboard operation
GSAP copied to clipboard

Issue with setting timeline progress to 0

Open Antonzo opened this issue 5 months ago • 0 comments

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);

Antonzo avatar Oct 01 '24 12:10 Antonzo