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

Function getPointerGridCell

src/hooks/usePanelDrag.ts:275–285  ·  view source on GitHub ↗
(metrics: ContainerMetrics, clientX: number, clientY: number)

Source from the content-addressed store, hash-verified

273}
274
275function getPointerGridCell(metrics: ContainerMetrics, clientX: number, clientY: number) {
276 const colUnit = metrics.cellWidth + metrics.colGap;
277 const rowUnit = metrics.rowHeight + metrics.rowGap;
278 const localX = clientX - metrics.rect.left - metrics.paddingLeft + metrics.scrollLeft;
279 const localY = clientY - metrics.rect.top - metrics.paddingTop + metrics.scrollTop;
280
281 const col = Math.max(0, Math.floor(localX / Math.max(1, colUnit)));
282 const row = Math.max(0, Math.floor(localY / Math.max(1, rowUnit)));
283
284 return { row, col };
285}
286
287function candidateContainsCell(candidate: PreviewCandidate, row: number, col: number) {
288 return (

Callers 1

usePanelDragFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected