hosanna-ui-docs - v0.9.0
    Preparing search index...

    BaseCollectionViewLayout provides core logic for laying out and managing cells in a collection view row. Handles cell pooling, rendering, focus, and header configuration.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    cellPadding: number = 0

    Padding between cells.

    cellsByIndex: Record<string, BaseCell.BaseCell> = {}

    Map of cell indices to cell instances.

    cellSize: [number, number] = ...

    Size of each cell as [width, height].

    enabled: boolean

    Whether this layout is enabled.

    Injected font manager for font lookups.

    hasHeader: boolean = true
    headerHeight: number = 50

    Height of the header.

    headerLabel: undefined | ISGNLabel

    Header label node, if present.

    instancePool: IInstancePool

    Injected instance pool for cell reuse.

    nodePool: INodePool

    Injected node pool for node reuse.

    numCols: number = 0

    Number of columns in the row.

    renderedCells: BaseCell.BaseCell[]

    Array of currently rendered cells.

    The row this layout manages.

    The content data for the row.

    rowSettings: undefined | ICollectionViewRowSettings

    The settings for the row.

    screenPosition: number = 0

    The current screen position (y offset).

    virtualPosition: number

    The current virtual scroll position.

    xOffset: number = 0

    Horizontal offset for content.

    Accessors

    Methods

    • Calculates and updates the visible cells based on the given virtual position WHEN SCROLLING UP AND DOWN

      Parameters

      • virtualPosition: number

        The virtual position to calculate the visible cells from.

        This method determines the range of cells that should be visible within the viewport, configures and renders them, and removes any cells that are no longer visible.

        The method performs the following steps:

        1. Calculates the first and last visible cell indices based on the virtual position and viewport width.
        2. Configures and renders the cells within the visible range.
        3. Removes cells that are no longer visible and releases them back to the cell pool.

      Returns void

    • Retrieves a cell at the specified index. If the cell does not exist, it reserves a new cell from the instancePool, sets it to visible, assigns the index, and stores it in the cellsByIndex array.

      Parameters

      • index: number

        The index of the cell to retrieve.

      Returns ICollectionViewCell

      The cell at the specified index, or a newly reserved cell if it did not exist.

      A warning if no cells are available in the instancePool.

    • Private

      Retrieves and configures cells for the currently visible items in the collection view.

      This method checks if the row is in a loading state and shows placeholders if true. Otherwise, it iterates over the visible items, configures each cell, and adds it to the rendered cells array.

      Returns void

    • Determines the index of an item based on a key press event.

      Parameters

      • key: string

        The key that was pressed. Expected values are Key.Left or Key.Right.

      • isLongPress: boolean

        A boolean indicating if the key press is a long press.

      Returns number

      The index of the item to focus on. Returns 0 if the left key is long pressed, the last item index if the right key is long pressed, or the clamped index based on the current focused index and the key pressed. Returns -1 for unsupported keys.

    • Calculates the on-screen position for a cell index.

      Parameters

      • index: number

        The cell index.

      • nextItemPosition: CollectionViewPosition

        The desired position for the next item.

      • offset: [number, number]

        The offset to apply.

      Returns undefined | [number, number]

      The [x, y] position or undefined if out of bounds.

    • Determines if this layout handles the given key press.

      Parameters

      • key: string

        The key pressed.

      • isLongPress: boolean

        Whether the key press is a long press.

      Returns boolean

      True if handled, false otherwise.

    • Determines if a cell index is visible on screen at the given virtual position.

      Parameters

      • index: number

        The cell index.

      • virtualPosition: number

        The virtual position.

      Returns boolean

      True if the cell is on screen, false otherwise.