Fix target point well inside shape issues

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
Mark Tolmacs 2025-04-15 17:15:53 +02:00
parent 7af00ca9b7
commit b63cd86cd6
No known key found for this signature in database

View file

@ -27,7 +27,9 @@ import {
PRECISION, PRECISION,
} from "@excalidraw/math"; } from "@excalidraw/math";
import { isPointOnShape } from "@excalidraw/utils/collision"; import { isPointInShape, isPointOnShape } from "@excalidraw/utils/collision";
import { getEllipseShape, getPolygonShape } from "@excalidraw/utils/shape";
import type { LocalPoint, Radians } from "@excalidraw/math"; import type { LocalPoint, Radians } from "@excalidraw/math";
@ -909,8 +911,14 @@ const getDistanceForBinding = (
bindableElement.height, bindableElement.height,
zoom, zoom,
); );
const isInside = isPointInShape(
point,
bindableElement.type === "ellipse"
? getEllipseShape(bindableElement)
: getPolygonShape(bindableElement),
);
return distance > bindDistance ? null : distance; return distance > bindDistance && !isInside ? null : distance;
}; };
export const bindPointToSnapToElementOutline = ( export const bindPointToSnapToElementOutline = (