Hosanna UI API v1.30.2-next
    Preparing search index...

    HorizontalRowLayout is a specialized implementation of BaseCollectionViewLayout designed to handle horizontal layouts for rows in a collection view. It manages the rendering, lifecycle events, and layout calculations for horizontally arranged rows.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    background: ISGNRectangle

    The background rectangle for the layout.

    cellPositions: number[] = []

    Array storing individual cell positions (virtual X positions) when isVariableWidth is true. Index corresponds to cell index.

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

    Map of cell indices to cell instances.

    cellWidths: number[] = []

    Array storing individual cell widths when isVariableWidth is true. Index corresponds to cell index.

    currentHeaderStyle: string = ''

    Current header style key for component-based headers.

    debugLabel: ISGNLabel

    The debug label for the layout.

    enabled: boolean = true

    Indicates 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.

    horizontalContentWidth: number = 0

    Cached physical content extent for variable-width rows.

    instancePool: IInstancePool

    Injected instance pool for cell reuse.

    lastUpdatedVisibleCellsVirtualPosition: number = 0

    The last updated visible cells virtual position.

    nodePool: INodePool

    Injected node pool for managing reusable nodes.

    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. Overrides base implementation to support variable cell widths.

      Parameters

      • virtualPosition: number

        The virtual position to calculate the visible cells from.

      • yPosition: number

        The y position (unused for horizontal rows).

      • useBufferCells: boolean = true

        Whether to add buffer cells for smooth scrolling.

      Returns void

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

      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. Overrides base implementation to support variable cell widths.

      Parameters

      • virtualPosition: number

        The virtual position.

      Returns number

      The cell index.

    • Gets the virtual position for a specific cell index. Returns the stored position if variable width is enabled, otherwise calculates using fixed width.

      Parameters

      • index: number

        The cell index.

      Returns number

      The virtual X position.

    • Gets the current cell positions array.

      Returns number[]

      Array of cell positions.

    • Gets the width for a specific cell index. Returns the stored width if variable width is enabled, otherwise returns the row's cellSize[0].

      Parameters

      • index: number

        The cell index.

      Returns number

      The cell width.

    • Gets the current cell widths array.

      Returns number[]

      Array of cell widths.

    • 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.

    • Gets the virtual position for a given cell index. Overrides base implementation to support variable cell widths.

      Parameters

      • index: number

        The cell index.

      Returns number

      The virtual position.

    • 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.

    • 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.

    • 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.

    • Determines if a cell index is visible on screen at the given virtual position. Overrides base implementation to support variable cell widths.

      Parameters

      • index: number

        The cell index.

      • virtualPosition: number

        The virtual position.

      Returns boolean

      True if the cell is on screen, false otherwise.

    • Called when the row enters the screen. Handles any necessary initialization or state updates for the row.

      Returns void

    • Renders the horizontal row at the specified virtual position. Overrides base implementation to support variable cell widths in rendering.

      Parameters

      • event: RenderEvent

        The render event containing virtual position and other details.

      Returns void

    • Sets the cell widths and positions arrays. This method should be called from the row's OnContentReady callback to populate the cellWidths and cellPositions arrays based on content.

      Parameters

      • widths: number[]

        Array of cell widths, indexed by cell index.

      • positions: number[]

        Array of cell virtual X positions, indexed by cell index.

      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.