streamlined connections

This commit is contained in:
peterkogo
2024-06-26 15:03:12 +02:00
parent 44254648c8
commit 5493f045ff
25 changed files with 355 additions and 474 deletions
@@ -1,9 +1,24 @@
<script lang="ts">
import { useConnection } from '@xyflow/svelte';
import { getBezierPath, useConnection } from '@xyflow/svelte';
const connection = useConnection();
let path: string | null = null;
$: if ($connection.inProgress) {
const { from, to, fromPosition, toPosition } = $connection;
const pathParams = {
sourceX: from.x,
sourceY: from.y,
sourcePosition: fromPosition,
targetX: to.x,
targetY: to.y,
targetPosition: toPosition
};
[path] = getBezierPath(pathParams);
}
</script>
{#if $connection.path}
<path d={$connection.path} fill="none" stroke={$connection.startHandle?.handleId} />
{#if $connection.inProgress}
<path d={path} fill="none" stroke={$connection.fromHandle.id} />
{/if}