mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-09-14 07:17:02 -04:00
Fix transparent shape binding
This commit is contained in:
parent
0313f6fb8b
commit
f46e247ba3
@ -313,6 +313,7 @@ const bindingStrategyForEndpointDragging = (
|
|||||||
elements,
|
elements,
|
||||||
elementsMap,
|
elementsMap,
|
||||||
zoom,
|
zoom,
|
||||||
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
// If the global bind mode is in free binding mode, just bind
|
// If the global bind mode is in free binding mode, just bind
|
||||||
|
@ -103,6 +103,7 @@ export type HitTestArgs = {
|
|||||||
threshold: number;
|
threshold: number;
|
||||||
elementsMap: ElementsMap;
|
elementsMap: ElementsMap;
|
||||||
frameNameBound?: FrameNameBounds | null;
|
frameNameBound?: FrameNameBounds | null;
|
||||||
|
overrideShouldTestInside?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const hitElementItself = ({
|
export const hitElementItself = ({
|
||||||
@ -111,6 +112,7 @@ export const hitElementItself = ({
|
|||||||
threshold,
|
threshold,
|
||||||
elementsMap,
|
elementsMap,
|
||||||
frameNameBound = null,
|
frameNameBound = null,
|
||||||
|
overrideShouldTestInside = false,
|
||||||
}: HitTestArgs) => {
|
}: HitTestArgs) => {
|
||||||
// Hit test against a frame's name
|
// Hit test against a frame's name
|
||||||
const hitFrameName = frameNameBound
|
const hitFrameName = frameNameBound
|
||||||
@ -143,7 +145,9 @@ export const hitElementItself = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Do the precise (and relatively costly) hit test
|
// 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
|
? // Since `inShape` tests STRICTLY againt the insides of a shape
|
||||||
// we would need `onShape` as well to include the "borders"
|
// we would need `onShape` as well to include the "borders"
|
||||||
isPointInElement(point, element, elementsMap) ||
|
isPointInElement(point, element, elementsMap) ||
|
||||||
@ -314,6 +318,7 @@ export const getHoveredElementForBindingAndIfItsPrecise = (
|
|||||||
elements: readonly Ordered<NonDeletedExcalidrawElement>[],
|
elements: readonly Ordered<NonDeletedExcalidrawElement>[],
|
||||||
elementsMap: NonDeletedSceneElementsMap,
|
elementsMap: NonDeletedSceneElementsMap,
|
||||||
zoom: AppState["zoom"],
|
zoom: AppState["zoom"],
|
||||||
|
shouldTestInside: boolean = true,
|
||||||
): {
|
): {
|
||||||
hovered: NonDeleted<ExcalidrawBindableElement> | null;
|
hovered: NonDeleted<ExcalidrawBindableElement> | null;
|
||||||
hit: boolean;
|
hit: boolean;
|
||||||
@ -332,6 +337,7 @@ export const getHoveredElementForBindingAndIfItsPrecise = (
|
|||||||
elementsMap,
|
elementsMap,
|
||||||
point,
|
point,
|
||||||
threshold: 0,
|
threshold: 0,
|
||||||
|
overrideShouldTestInside: shouldTestInside,
|
||||||
});
|
});
|
||||||
|
|
||||||
return { hovered: hoveredElement, hit };
|
return { hovered: hoveredElement, hit };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user