Class WindowedListModelAbstract

Windowed list abstract model.

Hierarchy (View Summary)

Implements

Constructors

Properties

_estimatedWidgetSize: number = WindowedList.DEFAULT_WIDGET_SIZE

Default widget size estimation

we always use estimateWidgetSize

_stateChanged: Signal<WindowedListModel, IChangedArgs<any, any, string>> = ...
estimateWidgetSize: (index: number) => number

Provide a best guess for the widget size at position index

This function should be very light to compute especially when returning the default size. The default value should be constant (i.e. two calls with null should return the same value). But it can change for a given index.

Type declaration

    • (index: number): number
    • Parameters

      • index: number

        Widget position

      Returns number

      Estimated widget size

paddingTop: number = 0

Top padding of the the outer window node.

scrollDownThreshold: number = 1

The overlap threshold used to decide whether to scroll down to an item below the viewport (smart mode). If the item overlap with the viewport is greater or equal this threshold the item is considered sufficiently visible and will not be scrolled to. The value is the number of pixels in overlap if greater than one, or otherwise a fraction of item height. By default the item is scrolled to if not full visible in the viewport.

scrollUpThreshold: number = 0

The underlap threshold used to decide whether to scroll up to an item above the viewport (smart mode). If the item part outside the viewport (underlap) is greater than this threshold then the item is considered not sufficiently visible and will be scrolled to. The value is the number of pixels in underlap if greater than one, or otherwise a fraction of the item height. By default the item is scrolled to if not full visible in the viewport.

widgetRenderer: (index: number) => Widget

Widget factory for the list items.

Caching the resulting widgets should be done by the callee.

Type declaration

    • (index: number): Widget
    • Parameters

      • index: number

        List index

      Returns Widget

      The widget at the given position

Accessors

Methods

  • Get the scroll offset to display an item in the viewport.

    By default, the list will scroll as little as possible to ensure the item is fully visible (auto). You can control the alignment of the item though by specifying a second alignment parameter. Acceptable values are:

    auto - Automatically align with the top or bottom minimising the amount scrolled, If alignPreference is given, follow such preferred alignment. If item is smaller than the viewport and fully visible, do not scroll at all. smart - If the item is significantly visible, don't scroll at all (regardless of whether it fits in the viewport). If the item is less than one viewport away, scroll so that it becomes fully visible (following the auto heuristics). If the item is more than one viewport away, scroll so that it is centered within the viewport (center if smaller than viewport, top-center otherwise). center - Align the middle of the item with the middle of the viewport (it only works well for items smaller than the viewport). top-center - Align the top of the item with the middle of the viewport (works well for items larger than the viewport). end - Align the bottom of the item to the bottom of the list. start - Align the top of item to the top of the list.

    An item is considered significantly visible if:

    • it overlaps with the viewport by the amount specified by scrollDownThreshold when below the viewport
    • it exceeds the viewport by the amount less than specified by scrollUpThreshold when above the viewport.

    Parameters

    • index: number

      Item index

    • align: ScrollToAlign = 'auto'

      Where to align the item in the viewport

    • margin: number = 0

      The proportion of viewport to add when aligning with the top/bottom of the list.

    • Optionalprecomputed: { currentOffset: number; itemMetadata: ItemMetadata; totalSize: number }

      Precomputed values to use when windowing is disabled.

    • OptionalalignPreference: BaseScrollToAlignment

      Allows to override the alignment of item when the auto heuristic decides that the item needs to be scrolled into view.

    Returns number

    The needed scroll offset

  • Return the viewport top position and height for range spanning from startIndex to stopIndex.

    Parameters

    • startIndex: number

      First item in viewport index

    • stopIndex: number

      Last item in viewport index

    Returns [number, number]

    The viewport top position and its height

  • WindowedListModel caches offsets and measurements for each index for performance purposes. This method clears that cached data for all items after (and including) the specified index.

    The list will automatically re-render after the index is reset.

    Parameters

    • index: number

    Returns void