Skip to content

VirtualState

Virtual window bookkeeping; modified in-place as scroll position changes.

Tracks virtualization state for row rendering. The grid only renders rows within the visible viewport window (start to end) plus overscan.

import type { VirtualState, InternalGrid } from '@toolbox-web/grid';
class MyPlugin extends BaseGridPlugin {
logVirtualWindow(): void {
const grid = this.grid as InternalGrid;
const vs = grid.virtualization;
console.log(`Row height: ${vs.rowHeight}px`);
console.log(`Visible rows: ${vs.start} to ${vs.end}`);
console.log(`Virtualization: ${vs.enabled ? 'on' : 'off'}`);
}
}
PropertyTypeDescription
enabledboolean
rowHeightnumber
bypassThresholdnumberThreshold for bypassing virtualization (renders all rows if totalRows <= bypassThreshold)
startnumber
endnumber
containerHTMLElement | unknownFaux scrollbar element that provides scroll events (AG Grid pattern)
viewportElHTMLElement | unknownRows viewport element for measuring visible area height
totalHeightElHTMLElement | unknownSpacer element inside faux scrollbar for setting virtual height
positionCacheRowPosition[] | unknownPosition cache for variable row heights. Index-based array mapping row index → {offset, height, measured}. Rebuilt when row count changes (expand/collapse, filter). null when using uniform row heights (default).
heightCacheobjectHeight cache by row identity. Persists row heights across position cache rebuilds. Uses dual storage: Map for string keys (rowId, __rowCacheKey) and WeakMap for object refs.
averageHeightnumberRunning average of measured row heights. Used for estimating unmeasured rows.
measuredCountnumberNumber of rows that have been measured.
variableHeightsbooleanWhether variable row height mode is active (rowHeight is a function).
cachedViewportHeightnumberCached viewport element height. Updated by ResizeObserver and force-refresh only.
cachedFauxHeightnumberCached faux scrollbar element height. Updated alongside viewport height.
cachedScrollAreaHeightnumberCached scroll-area element height. Updated alongside viewport/faux heights.
scrollAreaElHTMLElement | unknownCached reference to .tbw-scroll-area element. Set during scroll listener setup.
AI assistants: For complete API documentation, implementation guides, and code examples for this library, see https://raw.githubusercontent.com/OysteinAmundsen/toolbox/main/llms-full.txt