diff --git a/.changeset/serious-ducks-care.md b/.changeset/serious-ducks-care.md new file mode 100644 index 00000000..77c69a3d --- /dev/null +++ b/.changeset/serious-ducks-care.md @@ -0,0 +1,5 @@ +--- +'@xyflow/system': patch +--- + +Make it possible to stop autoPanOnDrag by setting it to false diff --git a/packages/system/src/xydrag/XYDrag.ts b/packages/system/src/xydrag/XYDrag.ts index eb2ea80a..0921e3ec 100644 --- a/packages/system/src/xydrag/XYDrag.ts +++ b/packages/system/src/xydrag/XYDrag.ts @@ -214,7 +214,13 @@ export function XYDrag voi return; } - const { transform, panBy, autoPanSpeed } = getStoreItems(); + const { transform, panBy, autoPanSpeed, autoPanOnNodeDrag } = getStoreItems(); + + if (!autoPanOnNodeDrag) { + autoPanStarted = false; + cancelAnimationFrame(autoPanId); + return; + } const [xMovement, yMovement] = calcAutoPan(mousePosition, containerBounds, autoPanSpeed);