jerosoler / Drawflow

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

Auto positioning #529

Closed quentingosset closed 1 year ago

quentingosset commented 2 years ago

I don't find if it is possible with your system to do auto positioning. I currently have a JSON that comes out of my A application where I have no positioning I just know the next and previous. Is it possible to do auto positioning? If so how and if not, do you have any idea how I can implement this?

jerosoler commented 2 years ago

Hi!

It does not have self-positioning.

I understand you want to do something like: https://jsoncrack.com/editor

You just have to count the nodes that each child has and position them according to the distance you want.

If you draw the boxes at 50px size and 70px spacing.

If you have a father and three children. The distances would be:

Parent: Left: 0px; Top: 0px

Child1: Left: 150px; Top: -120px; // 70 - 50px;

Child2: Left: 150px; Top: 0px;

Child3: Left: 150px; Top: 70px;

With a simple rule, I could add the children.

You can also see this other issue:

Jero

quentingosset commented 1 year ago

Thanks is working with your solution :)

kusal-saraf-cognoai commented 1 year ago

@quentingosset can you please share the code