diff --git a/.changeset/chilly-beans-juggle.md b/.changeset/chilly-beans-juggle.md new file mode 100644 index 00000000..64f1c8a0 --- /dev/null +++ b/.changeset/chilly-beans-juggle.md @@ -0,0 +1,5 @@ +--- +'@xyflow/system': patch +--- + +Fix nodeDragThreshold changing with zoom level diff --git a/packages/system/src/xydrag/XYDrag.ts b/packages/system/src/xydrag/XYDrag.ts index 1da0720d..c78e1035 100644 --- a/packages/system/src/xydrag/XYDrag.ts +++ b/packages/system/src/xydrag/XYDrag.ts @@ -334,8 +334,10 @@ export function XYDrag voi } if (!dragStarted) { - const x = pointerPos.xSnapped - (lastPos.x ?? 0); - const y = pointerPos.ySnapped - (lastPos.y ?? 0); + // Calculate distance in client coordinates for consistent drag threshold behavior across zoom levels + const currentMousePosition = getEventPosition(event.sourceEvent, containerBounds!); + const x = currentMousePosition.x - mousePosition.x; + const y = currentMousePosition.y - mousePosition.y; const distance = Math.sqrt(x * x + y * y); if (distance > nodeDragThreshold) {