chore: Element center point util (#9298)

This commit is contained in:
jhanma17dev
2025-04-09 17:04:51 +02:00
committed by GitHub
parent 6fc85022ae
commit dff69e9191
8 changed files with 49 additions and 78 deletions
+3 -3
View File
@@ -20,7 +20,7 @@ import {
isTextElement,
isFrameLikeElement,
} from "@excalidraw/element/typeChecks";
import { KEYS, arrayToMap } from "@excalidraw/common";
import { KEYS, arrayToMap, elementCenterPoint } from "@excalidraw/common";
import type { GlobalPoint, LocalPoint, Radians } from "@excalidraw/math";
@@ -151,7 +151,7 @@ export class Keyboard {
const getElementPointForSelection = (
element: ExcalidrawElement,
): GlobalPoint => {
const { x, y, width, height, angle } = element;
const { x, y, width, angle } = element;
const target = pointFrom<GlobalPoint>(
x +
(isLinearElement(element) || isFreeDrawElement(element) ? 0 : width / 2),
@@ -166,7 +166,7 @@ const getElementPointForSelection = (
(bounds[1] + bounds[3]) / 2,
);
} else {
center = pointFrom(x + width / 2, y + height / 2);
center = elementCenterPoint(element);
}
if (isTextElement(element)) {