开发者

jQuery's draggable plugin

开发者 https://www.devze.com 2023-03-27 23:44 出处:网络
When dragging an element can the draggable plugin prevent it from overflowing the other draggable elements? In other words, c开发者_Python百科an it stop dragging the element when it reaches the edge o

When dragging an element can the draggable plugin prevent it from overflowing the other draggable elements? In other words, c开发者_Python百科an it stop dragging the element when it reaches the edge of the other draggable element?


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/)


Exp:

$(element).draggable({ containment: 'body' });
0

精彩评论

暂无评论...
验证码 换一张
取 消