Jump to content
Search Community

Draggable update snap

Torben test
Moderator Tag

Go to solution Solved by Torben,

Recommended Posts

I have element which is draggable. On resize I change the transform and I change the draggable.vars with new snap points and call draggable.update()

I thought that would update the snap values.

But what happens is that it jumps when I start dragging after a resize.

 

So here's a Codepen. Try and click toggle to open it. Then you can drag it back out.

But if you resize the window after you've opened it, and then try an drag the element jumps to the old position.

What am I doing wrong?

 

See the Pen BabddVY?editors=1111 by tfl (@tfl) on CodePen

Link to comment
Share on other sites

Yep, whenever you work with transform-related properties, it's always best to go through GSAP for those because you generally get better performance and accuracy. For performance reasons, GSAP caches values internally on transforms.

 

Glad you figured it out. 💪

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...