desandro / draggabilly

:point_down: Make that shiz draggable
https://draggabilly.desandro.com
MIT License
3.86k stars 387 forks source link

Containing a draggable element in the user screen #155

Closed agonza1 closed 6 years ago

agonza1 commented 7 years ago

Is there a generic suggested approach for containing a draggable element inside the screen in a website?

I saw an approach using ~container: 'html'~ containment: 'html' in the initialization of the draggable object but it still allows the user to drag the object outside the screen. Also, it depends on the html element (which could be smaller than the screen?). Is there a more generic approach without additional elements such as the container?

gregvarghese commented 7 years ago

Ran into the same issue as I tried swapping in draggabilly to replace jquery ui draggable. It's containment, not container (which is what jquery ui draggable uses). Hope that helps you too!

desandro commented 6 years ago

containment: 'html' is the best approach.