Jump to content
Search Community

Eze

Members
  • Posts

    7
  • Joined

  • Last visited

Posts posted by Eze

  1. Thank you for your reply, thank you very much!
    My code is as follows, the div moves from 0px to 500px, during this animation, the user can drag the div, pressSign=true while dragging, gsap doesn't change the position of the div, when the user stops dragging, pressSign=false, I I want gsap to perfectly keep up with the tl animation in the TODO place, and the animation of the position dragged by the user reaches tl instead of jumping to tl in 0 seconds

     

     
         let pressSign = false;
         let pressTime = 0;
         let divEl = document.getElementById('div')
         const val = { x: 0 };
     
         const tl = gsap.timeline({
           paused: true,
         });
     
         tl.to(val, {
               x:500,
               duration:10
               onStart: function () {},
               onUpdate: function () {
                 if (pressSign) return;
                 divEl.style.left = val.x + 'px'
               },
         });
     
         function divElOnUp(){
           clearTimeout(pressTime);
            pressTime = setTimeout(() => {
             // TODO
     
             pressSign = false
            },2000)
         }
     
         function divElOnDown(){
           pressSign = true;
         }
×
×
  • Create New...