alyssaxuu / flowy

The minimal javascript library to create flowcharts ✨
MIT License
11.47k stars 998 forks source link

onSnap triggering only when a new block is added to the canvas #70

Closed fj-iv closed 4 years ago

fj-iv commented 4 years ago

I think it would be a nice feature that onSnap gives you the option to prevent block snapping triggered by reordering. If a certain group of blocks is tied to a determinate level, maybe we would want to allow the user to reorder the blocks inside that level but not to move them to upper/lower levels.

alyssaxuu commented 4 years ago

Hmm, not sure I understand what you're proposing. You mean to only allow a block to attach if it's on "level 3" for example? I think you might be able to do that, since the onSnap method has a parent parameter that gives you its properties, among them its parent ID, which programmatically you would be able to use to determine the level said parent is in (e.g. looking for a block with an ID that matches the parent ID, then getting the ID of said block, and so on). I don't think it's something that should come with the library, up to the developer, but would like to hear your thoughts if you think otherwise.