chore: Element center point util (#9298)
All checks were successful
Tests / test (push) Successful in 5m4s

This commit is contained in:
jhanma17dev 2025-04-09 10:04:51 -05:00 committed by GitHub
parent 6fc85022ae
commit dff69e9191
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 49 additions and 78 deletions

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)) {