diff --git a/frontend/src/GraphNode.svelte b/frontend/src/GraphNode.svelte index 79b9750..c97ea18 100644 --- a/frontend/src/GraphNode.svelte +++ b/frontend/src/GraphNode.svelte @@ -11,6 +11,7 @@ let hovering: boolean = false; let text_element: SVGTextElement; + let mainGroup: SVGGElement; $: cx = task === undefined || task.x === undefined ? 0 : task.x; $: cy = task === undefined || task.y === undefined ? 0 : task.y; @@ -45,12 +46,15 @@ dragging = true; e.preventDefault(); e.stopPropagation(); + + window.addEventListener("mousemove", drag) + window.addEventListener("mouseup", dragStop, { once: true }) } function drag(e: MouseEvent) { if (!draggingEnabled) return; if (!dragging) return; - let [x, y] = d3.pointer(e); + let [x, y] = d3.pointer(e, mainGroup); task.x = x; task.y = y; eventDispatcher("positionChange"); @@ -63,6 +67,7 @@ dragging = false; e.preventDefault(); e.stopPropagation(); + window.removeEventListener("mousemove", drag) } function dblclick(e: MouseEvent) { @@ -103,12 +108,11 @@ {#if task.task.type == 'label'}