[英]Child nodes not go out of the parent div
I have this div
: 我有这个div
:
<div id="composition_area" style="width: 700px; height: 600px; float:left; border: solid 2px">
<div id="a" class="a window" style="width: 80px; height: 80px; border: solid 1px" contenteditable="true">foo</div>
</div>
and inside of this with id="composition_area"
I add nodes with the jsplumb
. 并在其中使用id="composition_area"
添加带有jsplumb
节点。 In this example I have a node with id="a"
. 在此示例中,我有一个id="a"
的节点。 All the nodes are draggable and the user can move the divs anywhere he wants. 所有节点都是可拖动的,用户可以将div移动到他想要的任何位置。 But I want not to go out of the parent div. 但我想不出门父DIV的。 How can I do that? 我怎样才能做到这一点?
Look at the doc http://jsplumbtoolkit.com/doc/home#dragging 查看文档http://jsplumbtoolkit.com/doc/home#dragging
A common request is for the ability to contain the area within which an element may be dragged. 常见的要求是能够包含可在其中拖动元素的区域。 For jQuery this is as simple as providing a containment parameter: 对于jQuery,这就像提供一个containment参数一样简单:
jsPlumb.draggable($("someSelector"), { containment:"parent" }); jsPlumb.draggable($(“ someSelector”),{contains:“ parent”});
try this : 尝试这个 :
jsPlumb.draggable($("#composition_area"), {
containment:"parent"
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.