also postpone starting selection when clicking on a node

This commit is contained in:
peterkogo
2025-10-30 12:53:40 +01:00
committed by moklick
parent 0d2cda7dff
commit 07fbc7e34a
2 changed files with 4 additions and 14 deletions

View File

@@ -39,6 +39,7 @@
bind:edges bind:edges
fitView fitView
selectionMode={SelectionMode.Partial} selectionMode={SelectionMode.Partial}
multiSelectionKey={['Meta', 'Shift']}
selectionOnDrag selectionOnDrag
panOnScroll panOnScroll
paneClickDistance={100} paneClickDistance={100}

View File

@@ -120,13 +120,6 @@
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
} }
if (paneClickDistance === 0 || store.selectionKeyPressed) {
store.unselectNodesAndEdges();
onselectionstart?.(event);
selectionInProgress = true;
}
} }
function onPointerMove(event: PointerEvent) { function onPointerMove(event: PointerEvent) {
@@ -137,14 +130,10 @@
const mousePos = getEventPosition(event, containerBounds); const mousePos = getEventPosition(event, containerBounds);
const { startX = 0, startY = 0 } = store.selectionRect; const { startX = 0, startY = 0 } = store.selectionRect;
if ( if (!selectionInProgress) {
!selectionInProgress && const requiredDistance = store.selectionKeyPressed ? 0 : paneClickDistance;
event.target === container &&
!store.selectionKeyPressed &&
paneClickDistance > 0
) {
const distance = Math.hypot(mousePos.x - startX, mousePos.y - startY); const distance = Math.hypot(mousePos.x - startX, mousePos.y - startY);
if (distance <= paneClickDistance) { if (distance <= requiredDistance) {
return; return;
} }
store.unselectNodesAndEdges(); store.unselectNodesAndEdges();