Jump to content
Search Community

Eze

Members
  • Posts

    7
  • Joined

  • Last visited

Eze's Achievements

  1. Thank you, it's really more complicated. I thought there was an api that could get the tween value on the animation axis at a certain time in the future. I will study the sample code you gave, thank you very much!
  2. Thank you, is there a way to animate to the same position as box2 in 1 second after the mouse is lifted?
  3. It's very close now, I can't do it now, when onRelease, the div animation moves over, and now it jumps over instantly
  4. Thank you for your reply, do not pause the tween when dragging, the tween is still running
  5. 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; }
  6. const myObj = { x: 0 }; const myTween = gsap.to(myObj, { duration: 4, x: 100, }); const valueAt2s = myTween.vars.x * myTween.progress(2); console.log(valueAt2s); I expect valueAt2s=50
×
×
  • Create New...