Question

Currently the boxes I create in jsPlumb can be dragged off the screen, how do I prevent the boxes not be able to be dragged to the most left side of my screen? Like shown in this picture:

enter image description here

My page also has a menu on top, how do I apply the same tactics to prevent from my boxes being able to go over the menu bar?

Was it helpful?

Solution

By making use of option containment you can restrict the boxes to be draggable inside a particular DIV:

$('#BoxId').draggable({
    containment: "#containerId",
    drag:function(e){
        jsPlumb.repaint($(this));
    }
});

for jsPlumb draggable:

jsPlumb.draggable($("BoxId"), {
    containment:"containerId" // no need of '#'
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top