MCPcopy Create free account
hub / github.com/AmazingAng/PolyWorld / distanceToRect

Function distanceToRect

src/hooks/usePanelDrag.ts:253–258  ·  view source on GitHub ↗
(clientX: number, clientY: number, rect: DOMRect)

Source from the content-addressed store, hash-verified

251}
252
253function distanceToRect(clientX: number, clientY: number, rect: DOMRect) {
254 const dx = clientX < rect.left ? rect.left - clientX : clientX > rect.right ? clientX - rect.right : 0;
255 const dy = clientY < rect.top ? rect.top - clientY : clientY > rect.bottom ? clientY - rect.bottom : 0;
256 if (dx === 0 && dy === 0) return 0;
257 return dx * dx + dy * dy;
258}
259
260function scorePreviewRect(clientX: number, clientY: number, rect: DOMRect) {
261 const outsideDistance = distanceToRect(clientX, clientY, rect);

Callers 2

scorePreviewRectFunction · 0.85
usePanelDragFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected