MCPcopy Create free account
hub / github.com/adobe/react-spectrum / isPointInSafeArea

Function isPointInSafeArea

packages/react-aria/src/tooltip/useSafeArea.ts:85–98  ·  view source on GitHub ↗
(point: Point, triggerRect: DOMRect, overlayRect?: DOMRect)

Source from the content-addressed store, hash-verified

83}
84
85function isPointInSafeArea(point: Point, triggerRect: DOMRect, overlayRect?: DOMRect): boolean {
86 if (rectContains(triggerRect, point)) {
87 return true;
88 }
89 if (!overlayRect) {
90 return false;
91 }
92 if (rectContains(overlayRect, point)) {
93 return true;
94 }
95 // Otherwise, check whether the point is within the convex hull connecting the two rects.
96 let hull = convexHull([...rectCorners(triggerRect), ...rectCorners(overlayRect)]);
97 return hull.length >= 3 && isPointInPolygon(point, hull);
98}
99
100function rectContains(rect: DOMRect, point: Point): boolean {
101 return (

Callers 1

onPointerMoveFunction · 0.85

Calls 4

rectContainsFunction · 0.85
convexHullFunction · 0.85
rectCornersFunction · 0.85
isPointInPolygonFunction · 0.85

Tested by

no test coverage detected