Interface that VirtualList and VirtualGrid use to determine size and positioning offset for items in a single dimension.

interface ItemOffsetMapping {
    itemOffset(itemIndex: number): number;
    itemSize(itemIndex: number): number;
    offsetToItem(offset: number): [itemIndex: number, startOffset: number];
}

Methods

  • Offset from start of container to specified item

    itemOffset(n) should be equal to Sum{i:0->n-1}(itemSize(i))

    To efficiently support large containers, cost should be O(logn) or better.

    Parameters

    • itemIndex: number

    Returns number

  • Given an offset, return the index of the item that intersects that offset, together with the start offset of that item

    Parameters

    • offset: number

    Returns [itemIndex: number, startOffset: number]