Vertical positions of the body rows: the row heights as prefix sums plus optional extra heights behind single rows (the detail rows of master/detail). DOM-free; the table keeps one instance for its body (RenderScope.getBodyRowTop, RenderScope.getBodyRowIndexAtY).

  • Constant row height: positions are computed (i * h), no array.
  • Variable row heights: a Float64Array of rowCount + 1 prefix sums, built lazily on the first access after setRows – then getTop is O(1) and findIndexAt O(log n) (before 1.1.97 the table summed the heights of all rows above the viewport in every scroll frame).
  • Extras: sorted row indices with their extra heights and the prefix sums of the extras (O(log k) per lookup, k = number of extras). Changing one extra height (setExtraHeight) costs O(k), not O(n).

The slot of a row is the row plus its extra height below it: getTop(i + 1) = getTop(i) + getRowHeight(i) + getExtraHeight(i).

Example

const layout = new RowLayout();
layout.setRows(1000, i => i % 2 ? 30 : 50); // variable heights
layout.setExtras([12, 40], [180, 240]); // details behind rows 12 and 40
const top = layout.getTop(41); // top of row 41 below both details
const row = layout.findIndexAt(5000); // the row whose slot contains y = 5000

Since

1.1.97

Hierarchy

  • RowLayout

Constructors

Methods

  • The row whose slot (row + extra) contains y; rows of height 0 are skipped. Above the first row: 0, below the last: the last row, without rows: -1. O(1) for constant heights without extras, otherwise O(log n).

    Parameters

    • y: number

      px from the top of the first row

    Returns number

    the row index

  • The sum of the extra heights of the rows above a row.

    Parameters

    • rowIndex: number

      the row (rowCount = all extras)

    Returns number

    px

  • The top of a row: heights and extras of all rows above it. getTop(rowCount) = total height. The index is clamped to 0 … rowCount.

    Parameters

    • rowIndex: number

      the row

    Returns number

    px from the top of the first row

  • Sets, changes or (height ≤ 0) removes the extra height behind one row – O(k), the other extras stay.

    Parameters

    • rowIndex: number

      the row (ignored outside the rows)

    • height: number

      the extra height, ≤ 0 removes it

    Returns boolean

    true if something changed

  • Changes the extra height behind one row that already has one (see setExtras).

    Parameters

    • rowIndex: number

      the row

    • height: number

      the new extra height (> 0)

    Returns boolean

    false if the row has no extra or the height did not change

  • Sets the extra heights (e.g. detail rows) behind rows. Unsorted input is fine; heights of the same row add up; indices outside the rows and heights ≤ 0 are ignored. Replaces all previous extras.

    Parameters

    • rowIndices: ArrayLike<number>

      the rows with an extra height below them

    • heights: ArrayLike<number>

      the extra heights (same order as rowIndices)

    Returns void

  • Sets the rows. Prefix sums of variable heights are built lazily on the first access. Extras behind rows that no longer exist are dropped.

    Parameters

    • rowCount: number

      number of rows

    • heightOf: ((rowIndex) => number)

      height of a row (called only for variable heights)

        • (rowIndex): number
        • Parameters

          • rowIndex: number

          Returns number

    • Optional constantHeight: number

      the height of every row, if they are all equal (AreaModelIf.getConstantRowHeight)

    Returns void