fix: move elementCenterPoint from common/src/utils.ts to element/src/bounds.ts (#9647)

move elementCenterPoint from utils to bounds.ts
This commit is contained in:
zsviczian
2025-06-14 12:49:22 +02:00
committed by GitHub
parent 60512f13d5
commit 320af405e9
8 changed files with 26 additions and 27 deletions

View File

@@ -2,7 +2,6 @@ import rough from "roughjs/bin/rough";
import {
arrayToMap,
elementCenterPoint,
invariant,
rescalePoints,
sizeOf,
@@ -1244,3 +1243,14 @@ export const pointInsideBounds = <P extends GlobalPoint | LocalPoint>(
bounds: Bounds,
): boolean =>
p[0] > bounds[0] && p[0] < bounds[2] && p[1] > bounds[1] && p[1] < bounds[3];
export const elementCenterPoint = (
element: ExcalidrawElement,
elementsMap: ElementsMap,
xOffset: number = 0,
yOffset: number = 0,
) => {
const [x, y] = getCenterForBounds(getElementBounds(element, elementsMap));
return pointFrom<GlobalPoint>(x + xOffset, y + yOffset);
};