alyssaxuu / flowy

The minimal javascript library to create flowcharts ✨

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Conditional Snapping

ebihimself opened this issue · comments

commented

I wanted to know is there an API by the moment or in next releases that enables us to snap objects to each other based on the conditions.
for instance (regarding the demo version):
The action can not be snap to a logger object. But a logger object can be snap to action.

This is possible. Use the on snap method, you will get the parameter block, which is the DOM element the user is currently dragging, and the parameter parent, which is the DOM block it is about to snap to.

You can simply check which block is which by using an input, attribute, or some sort of identifier for each generated block, and access it through the parameters. If the connection is valid, use return true; and the blocks will snap. Otherwise, use return false; and the block that is being dragged will be deleted.