Inside detection for outline binding

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
Mark Tolmacs 2025-03-29 13:58:50 +01:00
parent 4ea534a732
commit d6d4d00f60
2 changed files with 32 additions and 30 deletions

View file

@ -63,7 +63,6 @@ import type {
ExcalidrawBindableElement,
FixedPointBinding,
FixedSegment,
NonDeletedExcalidrawElement,
} from "./types";
type GridAddress = [number, number] & { _brand: "gridaddress" };
@ -1221,18 +1220,22 @@ const getElbowArrowData = (
if (options?.isDragging) {
const elements = Array.from(elementsMap.values());
hoveredStartElement =
getHoveredElement(
origStartGlobalPoint,
elementsMap,
getHoveredElementForBinding(
tupleToCoors(origStartGlobalPoint),
elements,
elementsMap,
options?.zoom,
true,
true,
) || null;
hoveredEndElement =
getHoveredElement(
origEndGlobalPoint,
elementsMap,
getHoveredElementForBinding(
tupleToCoors(origEndGlobalPoint),
elements,
elementsMap,
options?.zoom,
true,
true,
) || null;
} else {
hoveredStartElement = arrow.startBinding
@ -2275,22 +2278,6 @@ const getBindPointHeading = (
origPoint,
);
const getHoveredElement = (
origPoint: GlobalPoint,
elementsMap: NonDeletedSceneElementsMap,
elements: readonly NonDeletedExcalidrawElement[],
zoom?: AppState["zoom"],
) => {
return getHoveredElementForBinding(
tupleToCoors(origPoint),
elements,
elementsMap,
zoom,
true,
true,
);
};
const gridAddressesEqual = (a: GridAddress, b: GridAddress): boolean =>
a[0] === b[0] && a[1] === b[1];