jerosoler / Drawflow

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

Connection Reroute #657

Closed ghost closed 1 year ago

ghost commented 1 year ago

Problem:

Strange behavior when adding a retoute point on a connection.

The reroute point seems to be placed incorrectly but can't seem to see any obvious reasons why that would happen

Expected Behavior

Taken from Drawflow example site: https://jerosoler.github.io/Drawflow/

image

Experienced Behavior

On my app

image

This behavior can also be replicated on the CodePen example site: https://codepen.io/KikePuma/pen/OJXXXdb

image

Version: Css: 0.0.59 JS: 0.0.59

Environment: Babel JSX React TailwindCss Jquery

jerosoler commented 1 year ago

Hello,

It seems to be a css problem. Surely some class is interfering.

Example with the minimum of operation.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/gh/jerosoler/Drawflow/dist/drawflow.min.css"
    />
    <script src="https://cdn.jsdelivr.net/gh/jerosoler/Drawflow/dist/drawflow.min.js"></script>
    <style>
      #drawflow {
        position: relative;
        width: 100%;
        height: 800px;
        border: 1px solid red;
      }
      </style>
  </head>
  <body>
    <div>
        <div id="drawflow"></div>  
    </div>
    <script>

    var id = document.getElementById("drawflow");

    const editor = new Drawflow(id);
    editor.reroute  =  true;

    editor.start();

    editor.addNode('test1', 1, 1, 440, 300, 'test1', {}, '<textarea></textarea><div id="content"></div>');
    editor.addNode('test1', 1, 1, 200, 300, 'test1', {}, '<textarea></textarea><div id="content"></div>');

    const nodeA = editor.addNode('NodeA', 1, 1, 440, 300, 'NodeA', {}, 'NodeA');
    const nodeB = editor.addNode('NodeB', 1, 1, 840, 300, 'NodeB', {}, 'NodeB');
    const nodeC = editor.addNode('NodeC', 1, 1, 840, 500, 'NodeC', {}, 'NodeC');
    editor.addConnection(nodeA, nodeB, "output_1", "input_1");  
    editor.addConnection(nodeA, nodeC, "output_1", "input_1");

</script> 
  </body>
</html>

It reminds me of one of these issues, see if any of them solve the problem.

ghost commented 1 year ago

Hi,

Thanks, will give those a look and see if I can find what's causing the conflict

ghost commented 1 year ago

I my goodness I am so dumb, I completely forgot that I actually copied my drawflow style sheet from that code pen site, when I disable that sheet it works as expected

Vanilla style with all other style sheets enabled (Working) image

So that works, I found another issue with the adding of reroutes, it seems that when you add a reroute point it adds the point in the right place but the incorrect segment of the svg path is adjusted

image

I will go through the open issues and see if there is already an issue logged for that, if not I'll make a new one

jerosoler commented 1 year ago

Use for fix adding points:

editor.reroute_fix_curvature = true;
ghost commented 1 year ago

Shot, thanks

Keep up the good work :)