Jump to content
Search Community

Issue with `Draggable.update` and scrollable elements

klaussner test
Moderator Tag

Recommended Posts

Hi GreenSock team,

 

I'm trying to use the Draggable.update function to make a Draggable stick to the cursor because in my application, some elements change their size during the drag. However, I noticed that Draggable.update yields different (and unexpected) results if the Draggable is inside a scrollable DOM element other than the body element. The attached CodePen demonstrates the problem.

 

If you drag the purple box to the bottom of the orange container, it doesn't stick to the cursor. It still moves while scrolling but at a lower speed. If you remove the outermost div, dragging and scrolling works as expected.

 

Do you know if/how I can call Draggable.update and make the element stick to the cursor in a scrollable element?

See the Pen rNVJzZW by cklaussner (@cklaussner) on CodePen

  • Like 1
Link to comment
Share on other sites

That's a tricky scenario indeed but I think I've got a fix I can apply in the next release which you can preview at https://s3-us-west-2.amazonaws.com/s.cdpn.io/16327/Draggable3.min.js

 

Here's a fork: 

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

 

(note that you can't just drop the new version into your old codepen because the GSDevTools file technically has Draggable inside of it, and that was loading AFTER the regular Draggable file, thus the Draggable in it overwrote the updated one). 

 

Does that work well for you? 

  • Like 3
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...