setting jsPlumb.draggable containment to any DOM element ?

1,180 views
Skip to first unread message

Wojciech Makowiecki

unread,
Oct 1, 2013, 11:21:12 AM10/1/13
to jsp...@googlegroups.com
Hi Simon,

Is it possible to set the containment to any DOM element 
instead of "parent" ?

e.g. like this 
jsPlumb.draggable("#window1", containment: "#some_DOM_element");

Many thanks,
Wojciech

Wojciech Makowiecki

unread,
Oct 1, 2013, 11:59:09 AM10/1/13
to jsp...@googlegroups.com
Actually, it works but ONLY for TOP and LEFT  borders of "#some_DOM_element"

jsPlumb.draggable("#window1", containment: "#some_DOM_element");

Would you point me in the direction to make it work 
for the bottom and right borders as well ?

Many thanks,
Wojciech

Wojciech Makowiecki

unread,
Oct 1, 2013, 2:54:38 PM10/1/13
to jsp...@googlegroups.com
The problem lies in jQuery and zooming, NOT in jsPlumb.

The containment works fine until I zoom, then the containment borders change,
so I'll probably will have to set them manually calculating the correct transform.

Simon Porritt

unread,
Oct 1, 2013, 3:11:23 PM10/1/13
to jsp...@googlegroups.com
Yet another reason for jsPlumb to handle dragging itself.  

Wojciech Makowiecki

unread,
Oct 2, 2013, 6:34:34 AM10/2/13
to jsp...@googlegroups.com
Indeed! Are you planning this in the near future?

Simon Porritt

unread,
Oct 2, 2013, 9:57:05 AM10/2/13
to jsp...@googlegroups.com
no, not really. there are reasons to do so but i'm not keen to reinvent the wheel. plus any drag stuff involving jsplumb needs to be able to integrate with the rest of the page, so it doesn't seem like a great idea from that perspective.

Simon Porritt

unread,
Oct 3, 2013, 5:42:06 PM10/3/13
to jsp...@googlegroups.com
...actually, i should qualify that: i *might* add support for dragging in jsplumb, but it would be a separate module, not bundled with the main release.  it would bring a few benefits: proper support for zoom and multiple scopes are the two main ones.  

Wojciech Makowiecki

unread,
Oct 3, 2013, 5:43:34 PM10/3/13
to jsp...@googlegroups.com
I see, but what's wrong with the zoom and scopes ?


On Thu, Oct 3, 2013 at 11:42 PM, Simon Porritt <simon....@gmail.com> wrote:
...actually, i should qualify that: i *might* add support for dragging in jsplumb, but it would be a separate module, not bundled with the main release.  it would bring a few benefits: proper support for zoom and multiple scopes are the two main ones.  

--
You received this message because you are subscribed to the Google Groups "jsPlumb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsplumb+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Simon Porritt

unread,
Oct 3, 2013, 5:48:28 PM10/3/13
to jsp...@googlegroups.com
if you set a CSS scale transform on an element, jQuery's draggable stuff reports the wrong location for the element being dragged.  that is the reason for jsPlumb's `setZoom` method: it inserts itself into the jQuery drag stuff and corrects the maths.

there is another issue with jquery drag/drop too: it fires a drop event for more than one element if a draggable is dropped on elements that are overlapping. people expect it, quite rightly, to fire a drop event only for the element that is on top of the stack. but it fires for all elements. i have "fixed" this in jsplumb, but only to the point where the single element that responds to the drop is indeterminate: it might be on top, it might not.

as for scopes, well jQuery only supports a single drag/drop scope.  but many people have, over the last couple of years, requested multiple scopes, because they would be cool.

Wojciech Makowiecki

unread,
Oct 3, 2013, 5:52:42 PM10/3/13
to jsp...@googlegroups.com
I see!
Thank you Simon, 
this is really important info!

Best,
Wojciech


--

Simon Porritt

unread,
Oct 3, 2013, 7:50:54 PM10/3/13
to jsp...@googlegroups.com
Sooner or later I am going to put up a FAQ with answers to these sorts of questions/gotchas.

for reference, here is the issue about dropping on multiple stacked elements:



Reply all
Reply to author
Forward
0 new messages