@jsvision/datagrid / nextCellIndex
Function: nextCellIndex()
nextCellIndex(
col,row,cols,rows):CellMove
Defined in: datagrid/src/navigation.ts:36
The cell one step forward (left-to-right, top-to-bottom) from (col, row) in a cols × rows grid, or 'exit' past the last cell of the last row (and for an empty grid). Past the last column it wraps to the first column of the next row. Pure — the grid maps the result onto its cursor signals.
Parameters
col
number
The current column index.
row
number
The current row index.
cols
number
The visible column count.
rows
number
The display row count.
Returns
The next cell, or 'exit' at the grid's end.
Example
ts
import { nextCellIndex } from '@jsvision/datagrid';
nextCellIndex(0, 0, 3, 3); // { col: 1, row: 0 }
nextCellIndex(2, 0, 3, 3); // { col: 0, row: 1 } — wraps
nextCellIndex(2, 2, 3, 3); // 'exit'