fix: Jump when cursor not moved

This commit is contained in:
Mark Tolmacs
2025-08-14 19:48:20 +02:00
parent 79a69b0db7
commit f14e6ea57f

View File

@@ -5935,6 +5935,10 @@ class App extends React.Component<AppProps, AppState> {
const scenePointer = viewportCoordsToSceneCoords(event, this.state);
const { x: scenePointerX, y: scenePointerY } = scenePointer;
this.lastPointerMoveCoords = {
x: scenePointerX,
y: scenePointerY,
};
if (
!this.state.newElement &&
@@ -6152,6 +6156,15 @@ class App extends React.Component<AppProps, AppState> {
: null,
});
});
this.scene.mutateElement(multiElement, {
points: [
...multiElement.points.slice(0, -1),
pointFrom<LocalPoint>(
this.lastPointerMoveCoords!.x - multiElement.x,
this.lastPointerMoveCoords!.y - multiElement.y,
),
],
});
}
this.bindModeHandler = null;
@@ -8599,8 +8612,22 @@ class App extends React.Component<AppProps, AppState> {
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<LocalPoint>(
(this.lastPointerMoveCoords?.x ??
pointerDownState.origin.x) - element.x,
(this.lastPointerMoveCoords?.y ??
pointerDownState.origin.y) - element.y,
),
],
});
}
this.bindModeHandler = null;