summaryrefslogtreecommitdiff
path: root/web/src/components/grid/cellAtCoord.ts
diff options
context:
space:
mode:
authorJosh Kingsley <josh@joshkingsley.me>2025-11-23 19:27:57 +0200
committerJosh Kingsley <josh@joshkingsley.me>2025-11-23 19:27:57 +0200
commit602145c956bb594ca0d0e10601cc4ad1a71cf70d (patch)
treed9f9980bd2054cff5819d01379f5c1c55f8eb66d /web/src/components/grid/cellAtCoord.ts
parentc2a6efb1b761014a90d90373cad47a14054af40b (diff)
feat: integrate web and doc packages
Diffstat (limited to 'web/src/components/grid/cellAtCoord.ts')
-rw-r--r--web/src/components/grid/cellAtCoord.ts40
1 files changed, 0 insertions, 40 deletions
diff --git a/web/src/components/grid/cellAtCoord.ts b/web/src/components/grid/cellAtCoord.ts
deleted file mode 100644
index dd594a4..0000000
--- a/web/src/components/grid/cellAtCoord.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import Coord from "../../math/Coord";
-import { CellRef } from "../../types";
-import { RenderedGrid, RenderedRow } from "./renderGrid";
-
-function rowAtCoord(grid: RenderedGrid, coord: Coord): RenderedRow | undefined {
- if (coord.y <= grid.rect.topLeft.y) {
- return grid.renderedRows[0];
- }
-
- if (coord.y >= grid.rect.bottomRight.y) {
- return grid.renderedRows.at(-1);
- }
-
- return grid.renderedRows.find((row) =>
- row.rect.verticallyContainsCoord(coord),
- );
-}
-
-export default function cellAtCoord(
- grid: RenderedGrid,
- x: number,
- y: number,
-): CellRef | undefined {
- const coord = new Coord(x, y);
- const row = rowAtCoord(grid, coord);
-
- if (!row) return;
-
- if (x <= row.rect.topLeft.x) {
- return row.renderedCells[0]?.cellRef;
- }
-
- if (x >= row.rect.bottomRight.x) {
- return row.renderedCells.at(-1)?.cellRef;
- }
-
- return row.renderedCells.find((cell) =>
- cell.rect.horizontallyContainsCoord(coord),
- )?.cellRef;
-}