jerosoler / Drawflow

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

createCurvature calculation options based on node input/output #773

Closed DannyV14 closed 8 months ago

DannyV14 commented 9 months ago

I have read through this issue multiple times: https://github.com/jerosoler/Drawflow/issues/20 I have implemented a switch case very similar to code found in that issue.

I have three different options of curvature.

  1. No center calculation
  2. Center_X calculation
  3. Center_Y calculation

The problem I am facing is that the optimal route of the curve depends heavily on the input/output port being used. As I have four ports that are input/output ambiguous (stacked on top of each with x-index changing). Sometimes the horizontal port connecting to a top port should have no curve as the best line. Or a port across from another would be best with a center_x approach.

I have attached a very poorly drawn guide trying to demonstrate the issue. Where the curve line runs along the side of the node.

DrawflowConnecitonNodeLogic

All of this to say, what do you think the best approach is here? I have looked into connection start/connection end/node moved events to try to determine the ports in use. But the createCurvature function only uses (start_x, start_y, end_x, end_y) so there are null reference possibilities by using variables existing outside of the curve function.

It is possible this is an unsolvable request. But just wanted to reach out for any potential advice!

Thanks!

jerosoler commented 9 months ago

Review this PR:

DannyV14 commented 8 months ago

Looks like that should work! I’ll give it a try. As always thank you so much for the quick response!

DannyV14 commented 8 months ago

The changes in this PR, can I override the drawflow default functions with these changes in my implementation?

jerosoler commented 8 months ago

My recommendation is that you directly copy the file https://github.com/jerosoler/Drawflow/blob/master/src/drawflow.js

And add changes manualy.

You can add it to your project like this: https://github.com/jerosoler/Drawflow/issues/526#issuecomment-1250828930