I'm trying to make draggable items stay inside their parent. If I make these items draggable using jquery-ui, everything works perfect. See the code:
$('.foo').draggable({
containment: $(this).parent(),
stack: '.foo',
snap: '.foo'
});
But if I try to make them draggable using jsPlumb, like this:
jsPlumb.draggable($('.foo'),{
containment:"parent",
snap: true
});
Everything works fine until I add endpoints. After that containment kinda works, but only for top and bottom borders. For left and right borders it does not work properly, draggable item leaves borders of parent div, but after I release mouse and try to drag the same item again, it jumps back to where it should have stayed, in its parent div. What's the problem?
Here is the jsfiddle. Drag any item to the right and drag it around, there will be no problems. Then press "Add new link" and drag it again. You will see the problem: