-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draggable elements goes out from the container if we move those towards top or left. #549
Comments
this is a function of jquery draggable. i can't help you with this. |
This happens in the "vanilla" version as well, so it's not just jQuery. If you drag off the right or bottom, you get scroll bars and all is well; if you drag off the left or top, your node is like the frisbee on the roof. What you'd like to be able to do is containment: [0, 0, 99999, 99999], so that you have a container that keeps you from going off the top or left, but the bottom and right containment is so loose that you practically never hit it. That looks like it works in jQuery jsPlumb, but not in DOM jsPlumb. DOM jsPlumb is using either the parent or the window size instead, I think? So if there's a bug to be found here, it's that DOM jsPlumb's implementation of containment doesn't give you correct array support. (I'm using the DOM version for the built-in multiple drag selection -- coding around containment was easier than coding multiple drag from scratch.) My solution was:
Basically, I'm implementing my own top / left containment. That's a bit clunky (in particular, this doesn't refresh the endpoints and connections when you drag off the edge) but it will save you from losing nodes entirely. I also tried a solution where I had a container, and then on drag start, I set the container height / width to very large numbers, so that as a practical matter, it was contained on top / left but not on bottom / right, but that failed with dragging multiple nodes. |
reopening for me to track...i will overlook this if it remains closed. |
tracking this now in Katavorio |
Could you explain how to use this feature properly? When I use |
It doesn't exist yet - it's down as an enhancement request for katavorio, the drag library. |
Any updates on this? @brian-davies solution works, but as he mentions, the endpoints and connections go out of bounds. |
I applied a workaround for now:
This will restrict top, left dragging to inside the container, while allowing bottom, right dragging to exceed the container. |
@prateekjahead your solution does the work but could you tell me how to restrict the same for bottom and right? Thanks. |
@shrutis0896 Did you try setting |
@prateekjahead so what does that "99999" represents in your above answer. I am not sure as to what I need to to set, will be helpful if you provide an example by providing the height and width of a container. |
@shrutis0896 You also need |
I am creating a project like workflow, in which i need to give functionality to user to add as many nodes he wants to add. I instantiated a jsPlumb instance using container (scrollable div) in which all the draggable nodes will be defined. Everything is working great except when i am dragging a node towards top or left in that container (scrollable div), it goes out of it and after releasing it i cannot take it back to the container. While it is working fine when nodes dragged towards right or bottom, scroll appears and node can be moved in scrolled container.
I have seen this problem in a demo, please refer below-
http://jsplumbtoolkit.com/demo/flowchart/jquery.html
I tried jsPlumb.draggable(el, { containment:"parent"}), after setting this param, scroll of container doesn't work properly. scroll doesn't appear if i drag the node towards right or bottom.
The text was updated successfully, but these errors were encountered: