chore(svelte) refactored connectionPath & connection

This commit is contained in:
Peter
2023-09-27 13:40:03 +02:00
parent 854a9d3606
commit 66caa4c8ca
7 changed files with 88 additions and 57 deletions
+12 -5
View File
@@ -66,6 +66,8 @@ const nullConnection: Connection = { source: null, target: null, sourceHandle: n
const alwaysValid = () => true;
let connectionStartHandle: ConnectingHandle | null = null;
function onPointerDown(
event: MouseEvent | TouchEvent,
{
@@ -129,15 +131,18 @@ function onPointerDown(
autoPanId = requestAnimationFrame(autoPan);
}
// Stays the same for all consecutive pointermove events
connectionStartHandle = {
nodeId,
handleId,
type: handleType,
};
updateConnection({
connectionPosition,
connectionStatus: null,
// connectionNodeId etc will be removed in the next major in favor of connectionStartHandle
connectionStartHandle: {
nodeId,
handleId,
type: handleType,
},
connectionStartHandle,
connectionEndHandle: null,
});
@@ -173,6 +178,7 @@ function onPointerDown(
isValid = result.isValid;
updateConnection({
connectionStartHandle,
connectionPosition:
closestHandle && isValid
? rendererPointToPoint(
@@ -220,6 +226,7 @@ function onPointerDown(
isValid = false;
connection = null;
handleDomNode = null;
connectionStartHandle = null;
doc.removeEventListener('mousemove', onPointerMove as EventListener);
doc.removeEventListener('mouseup', onPointerUp as EventListener);