Jump to content
Search Community

Draggable, programmatically "drag" to a position

Shaun Gorneau test
Moderator Tag

Recommended Posts

So, I'm using Draggable to move around a map that is larger than the viewport and bound to a container. That works perfectly. I have hotspots on the map that reveal info cards. When I click a hotspot, I would like to programmatically perform a drag as if I manually dragged the map from the "mousedown point" to the center of the screen. 

 

.to() works fine but doesn't respect the Draggable bounds (for obvious reasons). Is there a way to pass coordinates to a Draggable method such that it respects everything about the Draggable instance (bounds, inertia, etc.)?

 

Thanks Superheros!

Link to comment
Share on other sites

Got a minimal demo;)

 

No, there's not a simple way to tell a Draggable instance "hey, pretend the user is interactively dragging...but I'm actually doing it all programmatically" other than maybe faking a bunch of events dispatched by the element (sounds like a bad idea). 

 

I believe you could, however, tap into the Draggable's maxX, minX, maxY, and minY properties if you want to clamp the to() tween values accordingly. 

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