mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
revert: fix linear elements drifting away after multiple flips
This reverts commit bffc33dd3f
.
This commit is contained in:
parent
bffc33dd3f
commit
5931bf01b2
1 changed files with 1 additions and 29 deletions
|
@ -7,13 +7,7 @@ import { AppState, PointerDownState } from "../types";
|
||||||
import { updateBoundElements } from "../element/binding";
|
import { updateBoundElements } from "../element/binding";
|
||||||
import { arrayToMap } from "../utils";
|
import { arrayToMap } from "../utils";
|
||||||
import { KEYS } from "../keys";
|
import { KEYS } from "../keys";
|
||||||
import {
|
import { getCommonBoundingBox } from "../element/bounds";
|
||||||
getCommonBoundingBox,
|
|
||||||
getElementPointsCoords,
|
|
||||||
} from "../element/bounds";
|
|
||||||
import { isLinearElement } from "../element/typeChecks";
|
|
||||||
import { type ExcalidrawLinearElement } from "../element/types";
|
|
||||||
import { mutateElement } from "../element/mutateElement";
|
|
||||||
|
|
||||||
const enableActionFlipHorizontal = (
|
const enableActionFlipHorizontal = (
|
||||||
elements: readonly ExcalidrawElement[],
|
elements: readonly ExcalidrawElement[],
|
||||||
|
@ -92,15 +86,6 @@ const flipElements = (
|
||||||
): ExcalidrawElement[] => {
|
): ExcalidrawElement[] => {
|
||||||
const { minX, minY, maxX, maxY } = getCommonBoundingBox(elements);
|
const { minX, minY, maxX, maxY } = getCommonBoundingBox(elements);
|
||||||
|
|
||||||
const linearElements = elements
|
|
||||||
.filter((element): element is ExcalidrawLinearElement =>
|
|
||||||
isLinearElement(element),
|
|
||||||
)
|
|
||||||
.map((element) => {
|
|
||||||
const origCoords = getElementPointsCoords(element, element.points);
|
|
||||||
return [element, origCoords] as const;
|
|
||||||
});
|
|
||||||
|
|
||||||
resizeMultipleElements(
|
resizeMultipleElements(
|
||||||
{ originalElements: arrayToMap(elements) } as PointerDownState,
|
{ originalElements: arrayToMap(elements) } as PointerDownState,
|
||||||
elements,
|
elements,
|
||||||
|
@ -110,19 +95,6 @@ const flipElements = (
|
||||||
flipDirection === "horizontal" ? minY : maxY,
|
flipDirection === "horizontal" ? minY : maxY,
|
||||||
);
|
);
|
||||||
|
|
||||||
linearElements.forEach(([element, origCoords]) => {
|
|
||||||
const latestCoords = getElementPointsCoords(element, element.points);
|
|
||||||
const coordsDiffX =
|
|
||||||
origCoords[0] - latestCoords[0] + origCoords[2] - latestCoords[2];
|
|
||||||
const coordsDiffY =
|
|
||||||
origCoords[1] - latestCoords[1] + origCoords[3] - latestCoords[3];
|
|
||||||
|
|
||||||
mutateElement(element, {
|
|
||||||
x: element.x + coordsDiffX * 0.5,
|
|
||||||
y: element.y + coordsDiffY * 0.5,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
elements.forEach((element) => updateBoundElements(element));
|
elements.forEach((element) => updateBoundElements(element));
|
||||||
|
|
||||||
return elements;
|
return elements;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue