open-source-labs / Svelvet

🎛 A Svelte library for building dynamic, infinitely customizable node-based user interfaces and flowcharts
https://svelvet.io
2.5k stars 161 forks source link

Edgestyle straight is not working #476

Open jordandevogelaere opened 9 months ago

jordandevogelaere commented 9 months ago

``Hi,

When using "straight" as EdgeStyle I'm getting following errors in my console.

CleanShot 2023-09-11 at 16 35 30@2x
<Svelvet
    id="my-canvas"
    {height}
    minimap={true}
    controls={true}
    on:connection={(e) => connectionCreated(e)}
    zoom={0.8}
    edgeStyle="straight"
>
    {#each nodes as node (node.id)}
        <BaseNode
            nodeData={node}
            onAddNodeClicked={() => addNode(node.id)}
        />
    {/each}

</Svelvet>
dcs76 commented 8 months ago

In ../components/Edge/Edge.svelte, line 129, changing:

$:
  if (!step || edgeKey === "cursor" || $edgeType === "bezier") {
    path = `M ${sourceX},${sourceY} ${!straight && controlPointString} ${targetX},${targetY}`;
  }

to:

$:
  if (!step || edgeKey === "cursor" || $edgeType === "bezier") {
    path = `M ${sourceX},${sourceY} ${!straight ? controlPointString : ''} ${targetX},${targetY}`;
  }

fixes it for me.

Somfic commented 7 months ago

Can confirm this issue still persists in the latest version