MCPcopy Create free account
hub / github.com/editablejs/editable / getExitSideFromRect

Function getExitSideFromRect

packages/ui/src/hooks/use-pointer-in-transit.ts:13–31  ·  view source on GitHub ↗
(point: Point, rect: DOMRect)

Source from the content-addressed store, hash-verified

11type Polygon = Point[]
12
13function getExitSideFromRect(point: Point, rect: DOMRect) {
14 const top = Math.abs(rect.top - point.y)
15 const bottom = Math.abs(rect.bottom - point.y)
16 const right = Math.abs(rect.right - point.x)
17 const left = Math.abs(rect.left - point.x)
18
19 switch (Math.min(top, bottom, right, left)) {
20 case left:
21 return 'left'
22 case right:
23 return 'right'
24 case top:
25 return 'top'
26 case bottom:
27 return 'bottom'
28 default:
29 return null
30 }
31}
32
33function getPointsFromRect(rect: DOMRect) {
34 const { top, right, bottom, left } = rect

Callers 1

usePointerInTransitFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…