Fix transparent shape binding

This commit is contained in:
Mark Tolmacs 2025-07-27 15:06:23 +02:00
parent 0313f6fb8b
commit f46e247ba3
No known key found for this signature in database
2 changed files with 8 additions and 1 deletions

View File

@ -313,6 +313,7 @@ const bindingStrategyForEndpointDragging = (
elements,
elementsMap,
zoom,
true,
);
// If the global bind mode is in free binding mode, just bind

View File

@ -103,6 +103,7 @@ export type HitTestArgs = {
threshold: number;
elementsMap: ElementsMap;
frameNameBound?: FrameNameBounds | null;
overrideShouldTestInside?: boolean;
};
export const hitElementItself = ({
@ -111,6 +112,7 @@ export const hitElementItself = ({
threshold,
elementsMap,
frameNameBound = null,
overrideShouldTestInside = false,
}: HitTestArgs) => {
// Hit test against a frame's name
const hitFrameName = frameNameBound
@ -143,7 +145,9 @@ export const hitElementItself = ({
}
// Do the precise (and relatively costly) hit test
const hitElement = shouldTestInside(element)
const hitElement = (
overrideShouldTestInside ? true : shouldTestInside(element)
)
? // Since `inShape` tests STRICTLY againt the insides of a shape
// we would need `onShape` as well to include the "borders"
isPointInElement(point, element, elementsMap) ||
@ -314,6 +318,7 @@ export const getHoveredElementForBindingAndIfItsPrecise = (
elements: readonly Ordered<NonDeletedExcalidrawElement>[],
elementsMap: NonDeletedSceneElementsMap,
zoom: AppState["zoom"],
shouldTestInside: boolean = true,
): {
hovered: NonDeleted<ExcalidrawBindableElement> | null;
hit: boolean;
@ -332,6 +337,7 @@ export const getHoveredElementForBindingAndIfItsPrecise = (
elementsMap,
point,
threshold: 0,
overrideShouldTestInside: shouldTestInside,
});
return { hovered: hoveredElement, hit };