fix: Add binding update to manual stat changes (#8183)

Manual stats changes now respect previous element bindings.
This commit is contained in:
Márk Tolmács 2024-07-01 09:45:31 +02:00 committed by GitHub
parent 04668d8263
commit 66a2f24296
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 327 additions and 162 deletions

View file

@ -1,4 +1,8 @@
import type { ElementsMap, ExcalidrawElement } from "../../element/types";
import type {
ElementsMap,
ExcalidrawElement,
NonDeletedSceneElementsMap,
} from "../../element/types";
import { rotate } from "../../math";
import type Scene from "../../scene/Scene";
import StatsDragInput from "./DragInput";
@ -27,7 +31,7 @@ const moveElements = (
changeInTopY: number,
elements: readonly ExcalidrawElement[],
originalElements: readonly ExcalidrawElement[],
elementsMap: ElementsMap,
elementsMap: NonDeletedSceneElementsMap,
originalElementsMap: ElementsMap,
) => {
for (let i = 0; i < elements.length; i++) {
@ -66,8 +70,9 @@ const moveGroupTo = (
nextX: number,
nextY: number,
originalElements: ExcalidrawElement[],
elementsMap: ElementsMap,
elementsMap: NonDeletedSceneElementsMap,
originalElementsMap: ElementsMap,
scene: Scene,
) => {
const [x1, y1, ,] = getCommonBounds(originalElements);
const offsetX = nextX - x1;
@ -146,6 +151,7 @@ const handlePositionChange: DragInputCallbackType<
elementsInUnit.map((el) => el.original),
elementsMap,
originalElementsMap,
scene,
);
} else {
const origElement = elementsInUnit[0]?.original;