Search code examples
javascriptdraggablegsap

GSAP timeline with repeat is breaking the draggable ease flow


I see that using the "repeat:-1" in timeline is breaking the draggable behavior ease flow. https://codepen.io/GreenSock/pen/WNedayo?editors=1111

If use "repeat:-1" to loop the animation in above code pen code. observe that drag ease is breaking.

.to("#Handle", {
  duration: 100,
  x: 1000,
  repeat:-1,
  ease: "none"
});

Solution

  • You need to put repeat in right place:

    handle.t1 = gsap.timeline({
      repeat: -1,
      onStart() {
        console.log('start');
      },
      onComplete() {
        console.log('complete');
      }
    })
    .to("#Handle", {
      duration: 100,
      x: 1000,
      ease: "none"
    });