Hosanna UI API v1.30.2-next
    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

    background: ISGNRectangle

    The background rectangle for the layout.

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

    Map of cell indices to cell instances.

    currentHeaderStyle: string = ''

    Current header style key for component-based headers.

    debugLabel: ISGNLabel

    The debug label for the layout.

    enabled: boolean

    Whether this layout is enabled.

    Injected font manager for font lookups.

    hasHeader: boolean = true

    Whether this layout has a header.

    headerFragment: undefined | IViewFragment = undefined

    Header fragment for component-based headers.

    headerLabel: undefined | ISGNLabel

    Header label node, if present.

    instancePool: IInstancePool

    Injected instance pool for cell reuse.

    lastUpdatedVisibleCellsVirtualPosition: number = 0

    The last updated visible cells virtual position.

    nodePool: INodePool

    Injected node pool for node reuse.

    onReleaseFinish:
        | undefined
        | ((layout: BaseCollectionViewLayout.BaseCollectionViewLayout) => void) = undefined

    The callback to invoke when the row is released.

    onRowRenderFinish: undefined | ((event: RenderEvent) => void) = undefined

    The callback to invoke at the end of row layout rendering.

    onRowRenderStart: undefined | ((event: RenderEvent) => void) = undefined

    The callback to invoke at the start of row layout rendering.

    renderedCells: BaseCell.BaseCell[]

    Array of currently rendered cells.

    row: ResolvedHorizontalReadingDirectionRow

    The row this layout manages.

    screenPosition: number = 0

    The current screen position (y offset).

    Injected view fragment provider for component-based headers.

    virtualPosition: number

    The current virtual scroll position.

    Accessors

    • get numberOfItems(): number

      Returns the number of items in the row.

      Returns number

    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.
      • yPosition: number
      • useBufferCells: boolean = true

      Returns void

    • Configures the header for the row based on settings. Supports both legacy single-label headers and new component-based headers.

      Returns void

    • Converts placeholder cells to real cells (to be implemented by subclasses).

      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.

      The pool key is normally the row's cellSettingsKey (or loadingCellStyleKey for loading placeholders). When the row has useMixedCellStyleKeys, each item may supply its own cellSettingsKey so different cells in the same row can use different styles.

      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.

    • Gets the cell index at a given virtual position.

      Parameters

      • virtualPosition: number

        The virtual position.

      Returns number

      The cell index.

    • 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

    • Gets the width for a specific cell index.

      Parameters

      • index: number

        The cell index.

      Returns number

      The cell width.

    • Gets the item index whose center is closest to the stored focused cell X position. Used for FocusOnClosestItem strategy.

      Parameters

      • direction: number

      Returns number

      The item index closest to the stored X position.

    • Derives the view status a cell at the given index should have right now, from the collection view's focus state rather than whatever status the cell last wore. This is what lets retained/pooled cells self-heal: the focused cell picks up Focused when it materializes (even if focus was applied while it was off-screen), and any other cell sheds a stale Focused left over from focus-index desync during animations.

      The focused cell is identified via the collection view's committed focusedIndices (the per-row focusedIndex can lag behind during animation completions). An existing FocusFootprint is preserved (see below) rather than re-derived.

      Parameters

      • index: number

        The cell index.

      • currentStatus: ViewStatus

        The status the cell currently wears (used to preserve footprints).

      Returns ViewStatus

    • Returns the horizontal content extent in physical layout coordinates.

      Returns number

    • Gets the virtual position for a given cell index and position.

      Parameters

      • index: number

        The cell index.

      Returns number

      The virtual position.

    • Returns the initial horizontal offset that exposes logical item zero.

      Returns number

    • Parameters

      • itemIndex: number

      Returns number

    • Returns the largest valid horizontal scroll offset for this row.

      Parameters

      • viewportWidth: number = ...

      Returns number

    • Gets the next item index when moving vertically within row. Override this function if your row has more than one item per sub-row, and you want to move to the next item when moving vertically. That is, for rows containing one line of items (for instance, HorizontalRow), the method returns -1 (because the next or previous line of items does not exist)

      Parameters

      • direction: number

        1 for up, 1 for down

      Returns number

    • Gets the next page item index when moving horizontally within row. Override this function if your row has more than one item per sub-row, and you want to move to the next page item when moving horizontally.

      Parameters

      • direction: number

        1 for left, 1 for right

      Returns number

      The index of the next page item.

    • Gets the rendered cell at the specified index.

      Parameters

      • index: number

        The cell index.

      Returns undefined | ICollectionViewCell

      The rendered cell, if any.

    • Gets the rendered cell at a given virtual position.

      Parameters

      • virtualPosition: number

        The virtual position.

      Returns undefined | ICollectionViewCell

      The rendered cell.

    • Calculates the on-screen position for a cell index, accounting for the current horizontal scroll (virtualPosition). Used by pointer/touch focus so the focus indicator follows the item to its scrolled location rather than its release point. The returned X is clamped to the visible viewport so the indicator never renders past the row edges. Assumes a horizontal layout; subclasses may override.

      Parameters

      • index: number

        The cell index.

      • offset: [number, number]

        The base offset to apply ([x, y]); offset[0] is the minimum X, offset[1] is the Y.

      Returns undefined | [number, number]

      The clamped [x, y] screen position, or undefined if the index is out of bounds.

    • Gets the target item index in the horizontal direction.

      Parameters

      • direction: number

        1 for left, 1 for right

      • isLongPress: boolean

        Whether the key press is a long press.

      Returns number

      The index of the target item.

    • Returns the [x, y] virtual position within this row necessary to bring the target item index into view according to the requested position strategy. Base implementation returns a default x using xOffset and a y based on the row's rendered list position and screen position. Specialized layouts should override this to provide accurate item positions.

      Parameters

      • index: number

      Returns number

    • Returns the vertical position of the item index.

      Parameters

      • index: number

        The item index.

      Returns number

      The vertical position of the item index. The same as getVerticalCorrectedPositionForItemIndex, but without the screen position offset.

    • Parameters

      • index: number

      Returns number

    • Gets the virtual vertical position for a specific row index related to the row header.

      Parameters

      • rowIndex: number

        The item index.

      Returns number

      The virtual vertical position for the row.

    • Gets the virtual row index for the target index.

      Parameters

      • targetIndex: number

        The target index.

      Returns number

      The virtual row index.

    • Gets the number of virtual rows in the layout.

      Returns number

      The number of virtual rows in the layout.

    • Determines if a cell index is in the modified floating focus area at the given virtual position. The modified floating focus area is the floating focus area without the xOffset. This is used for horizontal scrolling with floating focus.

      Parameters

      • index: number

        The cell index.

      • virtualPosition: number

        The virtual position.

      Returns boolean

      True if the cell is in the modified floating focus area, false otherwise.

    • Called when the row enters the screen. Prepares visible cells and header.

      Returns void

    • Called when the row exits the screen. Releases all rendered cells and hides the header.

      Returns void

    • Called before the layout is released back to the pool. Releases all cells, resets virtual position, and clears rendered cells.

      Returns void

    • Called before the layout is reused from the pool. Resets virtual position, clears rendered cells, and hides the header.

      Returns void

    • Refreshes only compatibility-installed direction members after a locale change.

      Parameters

      • readingDirection: ReadingDirection

      Returns void

    • Returns void

    • Returns void

    • Renders the row and its cells at the given position.

      Parameters

      Returns void

    • Renders the row as a hidden row (to be implemented by subclasses).

      Returns void

    • Parameters

      • y: number
      • color: string = '#ff0000'

      Returns void

    • Parameters

      • y: number

      Returns void

    • Determines if the visible cells should be recalculated.

      Parameters

      • yPosition: number

        The virtual screen y position.

      Returns boolean

      True if the visible cells should be recalculated, false otherwise.

    • Shows placeholder cells (not implemented).

      Returns void