View as Markdown

API reference: @salmonui/data-grid/engine

ScrollMappinginterface

import type { ScrollMapping } from '@salmonui/data-grid/engine';
interface ScrollMapping {
    readonly compressed: boolean;
    readonly scrollHeight: number;
    readonly totalHeight: number;
    readonly ratio: number;
    toVirtual(scrollTop: number): number;
    toPhysical(virtualTop: number): number;
    segmentAt(virtualTop: number, estimatedRowHeight: number): {
        index: number;
        count: number;
        rowsPerSegment: number;
    } | null;
}

Maps between the physical scroll offset of the scroll container and the virtual offset of the row model. Below maxScrollHeight the mapping is the identity. Above it the physical scroll height is capped and the offset is mapped linearly (scroll height compression), so 10M+ rows stay reachable in browsers that cap element heights (~17.9M px Firefox, ~33.5M px Chromium).

ScrollMapping members (7)
NameSignatureDescription
compressedreadonly compressed: boolean;
scrollHeightreadonly scrollHeight: number;

Physical height of the scrollable content.

totalHeightreadonly totalHeight: number;
ratioreadonly ratio: number;

Virtual px per physical px (1 when not compressed).

toVirtualtoVirtual(scrollTop: number): number;
toPhysicaltoPhysical(virtualTop: number): number;
segmentAtsegmentAt(virtualTop: number, estimatedRowHeight: number): { index: number; count: number; rowsPerSegment: number; } | null;

Deterministic segment of a virtual offset; null when not compressed.