computeScrollYForRow

Computes the vertical translation that pins a row at the fixed focus line

Available since @roku-sdk/flex-grid 3.3.0

import { computeScrollYForRow } from "@roku-sdk/flex-grid/geometry";

Also exported as computeScrollYForRow from @roku-sdk/flex-grid (deprecated).

Deprecated: computeScrollYForRow. Import from @roku-sdk/flex-grid/geometry instead. The root export will be removed in the next major version.

computeScrollYForRow(targetRow: number, params: FixedFocusYParams): number

Description

Computes the vertical translation that pins a row at the fixed focus line.

Use this helper in a custom VerticalFocusStrategyPlugin or geometry-aware InitGridPlugin. Import it from @roku-sdk/flex-grid/geometry.

Content that fits the viewport, including zero rows, returns containerY. Rows at or beyond the end-zone start use the end-zone translation. Negative targets are not clamped and are passed to getRowY; callers should resolve looping targets into data-row indices first.

Parameters

NameTypeDescription
targetRownumberTarget data-row index, as a zero-based integer.
paramsFixedFocusYParamsViewport and row geometry in pixels, with non-decreasing row positions.

Return values

The vertical content translation in pixels.

Example

computeScrollYForRow(1, { containerY: 50, viewportHeight: 200, numRows: 4, getRowY: r => r * 100, getRowHeight: () => 100 }); // -50

Did this page help you?