Jump to content
Search Community

Position of items are not the same when dragging Multiple Items with autoscroll

kichun1010 test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Hi, i am trying to drag multiple items with autoscroll. In my case, two items are in different container therefore event listener 'scroll' is used to change the scrollLeft of another container. But i found that the one without dragging will move a little bit forward when it is scrolling. It will be correct after scrolling. Is there any problem in my code?

See the Pen PoJrJVN by lesley0911 (@lesley0911) on CodePen

Link to comment
Share on other sites

sync.gif.e6dd240d507d11927efe79e47a406d01.gif

 

(animation is paused to show that boxes are not aligned while autoscrolling)

 

this is what I'm seeing. I'm guessing your scroll eventlisteners are firing at a totally different rate than Draggable's onUpdate. 

 

I doubt this is a Draggable issue as Draggable is doing exactly what it should in autoscrolling the parent of the thing you are dragging.

 

 

  • Like 1
Link to comment
Share on other sites

  • Solution

I think the main problem is that when it does an "autoScroll", you're not necessarily dragging the element, thus onDrag isn't fired. That's not a bug. You could just tap into GSAP's ticker and run your update on each tick WHILE it's pressed like this: 

 

See the Pen QWaObGB?editors=0010 by GreenSock (@GreenSock) on CodePen

 

There are several other ways you could do it; this is just one. 

 

Does that help? 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...