interface UseVirtualListBaseOptions {
/**
* The container element, of type ElementTarget, typically the scrollable element.
*/
containerTarget: NonNullable<ElementTarget<HTMLElement>>
/**
* The wrapper element, of type ElementTarget, typically the element containing all items.
*
* MarginTop and height (marginLeft and width for horizontal scrolling) will be set to the total height (width) of all items.
*/
wrapperTarget: NonNullable<ElementTarget<HTMLElement>>
/**
* The number of items to additionally render outside the viewport (above and below for vertical scrolling, left and right for horizontal).
*
* @defaultValue 5
*/
overscan?: number
}
interface UseVerticalVirtualListOptions<D> extends UseVirtualListBaseOptions {
/**
* The height of each item, or a function returning the height of each item, accepting parameters index and item.
*
* When `itemHeight` is set, the list is in vertical rendering mode, with higher priority than `itemWidth`.
*/
itemHeight: number | ((index: number, item: D) => number)
}
interface UseHorizontalVirtualListOptions<D> extends UseVirtualListBaseOptions {
/**
* The width of each item, or a function returning the width of each item, accepting parameters index and item.
*
* When `itemWidth` is set and `itemHeight` is not, the list is in horizontal rendering mode.
*/
itemWidth: number | ((index: number, item: D) => number)
}
export type UseVirtualListOptions<D> = UseVerticalVirtualListOptions<D> | UseHorizontalVirtualListOptions<D>