From 6db03ec54ec8870a08902cc222881957f827d2c7 Mon Sep 17 00:00:00 2001 From: Mark Tolmacs Date: Thu, 14 Aug 2025 19:48:20 +0200 Subject: [PATCH] fix: Jump when cursor not moved --- packages/excalidraw/components/App.tsx | 29 +++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/excalidraw/components/App.tsx b/packages/excalidraw/components/App.tsx index 95abc9baaf..dacc771443 100644 --- a/packages/excalidraw/components/App.tsx +++ b/packages/excalidraw/components/App.tsx @@ -5983,6 +5983,10 @@ class App extends React.Component { const scenePointer = viewportCoordsToSceneCoords(event, this.state); const { x: scenePointerX, y: scenePointerY } = scenePointer; + this.lastPointerMoveCoords = { + x: scenePointerX, + y: scenePointerY, + }; if ( !this.state.newElement && @@ -6200,6 +6204,15 @@ class App extends React.Component { : null, }); }); + this.scene.mutateElement(multiElement, { + points: [ + ...multiElement.points.slice(0, -1), + pointFrom( + this.lastPointerMoveCoords!.x - multiElement.x, + this.lastPointerMoveCoords!.y - multiElement.y, + ), + ], + }); } this.bindModeHandler = null; @@ -8788,8 +8801,22 @@ class App extends React.Component { pointerDownState.origin.y; pointerDownState.drag.hasOccurred = true; - this.setState(newState); + flushSync(() => { + this.setState(newState); + }); } + + this.scene.mutateElement(element, { + points: [ + ...element.points.slice(0, -1), + pointFrom( + (this.lastPointerMoveCoords?.x ?? + pointerDownState.origin.x) - element.x, + (this.lastPointerMoveCoords?.y ?? + pointerDownState.origin.y) - element.y, + ), + ], + }); } this.bindModeHandler = null;