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

    GridRowLayout is a specialized implementation of BaseCollectionViewLayout designed to handle grid-based layouts for rows in a collection view. It manages the rendering, focus handling, and layout calculations for grid rows.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    Accessors

    Methods

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

    instancePool: IInstancePool

    Injected instance pool for cell reuse.

    lastUpdatedVisibleCellsVirtualPosition: number = 0

    The last updated visible cells virtual position.

    lastUpdatedVisibleCellsYPosition: number = 0

    The y position of layout when visible cells were calculated last time.

    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.

    viewportHeight: number = 1080

    The height of the viewport for visible rows.

    viewportWidth: number = 1700

    The width of the viewport for visible rows.

    virtualPosition: number

    The current virtual scroll position.

    yOffset: number = 0

    The vertical offset for rendering rows.

    Accessors

    • get numberOfItems(): number

      Returns the number of items in the row.

      Returns number

    Methods

    • Calculates the visible cells based on the virtual position. Determines which cells should be rendered and removes those that are no longer visible.

      Parameters

      • virtualPosition1: number
      • 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

    • 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 specific virtual position.

      Parameters

      • virtualPosition: number

        The virtual position.

      Returns number

      The index of the cell at the specified position.

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

      Returns number

      The item index closest to the stored X position.

    • 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 center X position of a column in the grid layout.

      Parameters

      • col: number

        The column index.

      Returns number

      The center X position of the column.

    • Gets the center X position of an item at the given index in grid layout.

      Parameters

      • index: number

        The item index.

      Returns number

      The center X position of the item.

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

    • Parameters

      • logicalColumn: number

      Returns number

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

      Parameters

      • direction: number

        1 for left, 1 for right

      • isLongPress: boolean

      Returns number

    • Returns the relative Y within this row for the given item index based on the current virtual position. Used by CollectionView to compute a global target Y when animating to a specific row+item combination.

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

    • Renders the grid row at the specified virtual position. Calculates the position of each cell and updates their translations.

      Parameters

      • event: RenderEvent

        The render event containing virtual position and other details.

      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.