Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery's draggable plugin

When dragging an element can the draggable plugin prevent it from overflowing the other draggable elements? In other words, can it stop dragging the element when it reaches the edge of the other draggable element?

like image 865
Wopa Avatar asked Sep 28 '26 19:09

Wopa


1 Answers

You can contain the dragging within a parent element - if you contain all of the draggables within one element and set that as the containment, they will not be able to be dragged beyond that.

$( ".selector" ).draggable({ containment: 'parent' });

(from http://jqueryui.com/demos/draggable/)

like image 78
yoozer8 Avatar answered Sep 30 '26 14:09

yoozer8



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!