jerosoler / Drawflow

Simple flow library 🖥️🖱️
https://jerosoler.github.io/Drawflow/
MIT License
4.65k stars 722 forks source link

Restrict node overlap while dragging existing node and new node #465

Closed Sri-5555 closed 1 year ago

Sri-5555 commented 2 years ago

How to restrict overlap of node while dragging existing or adding new node over other node overlap node

jerosoler commented 2 years ago

By default there is nothing implemented. But what would have to be done is to detect the collisions.

https://developer.mozilla.org/en-US/docs/Games/Techniques/2D_collision_detection

You could use the events of "nodeCreated", "nodeMoved". To detect when a node is created or moved.

Once this is done, detect if there is a collision and if there is, move the node.

Move node with javascript:

codeandcore commented 2 years ago

Hi @jerosoler can you please help me that how can i get position of any node in drawflow when i move using (nodeMoved event) so i can manage collision detaction

Thanks

jerosoler commented 2 years ago

Use editor.export() to gell all info.

Or document.querySelectorAll(".drawflow-node "); and get left and top position

vnomohan commented 10 months ago

is there any sample code for this? could you please share it here