/** * HeightManager handles row height caching and calculations for virtual scrolling. * It maintains a cache of measured row heights and provides methods to calculate * scroll positions, visible ranges, and total heights. */ export declare class HeightManager { /** Cache of measured row heights by row ID. */ private heightCache; /** Estimated height for unmeasured rows. */ private estimatedRowHeight; /** Sum of all measured heights. */ private totalMeasuredHeight; /** Number of measured rows. */ private measuredCount; /** * Creates a new HeightManager. * * @param estimatedRowHeight - Initial estimated height for unmeasured rows. */ constructor(estimatedRowHeight?: number); /** * Set or update the height for a specific row. * * @param rowId - The unique identifier of the row. * @param height - The measured height of the row in pixels. * @returns True if the height changed, false otherwise. */ setHeight(rowId: string, height: number): boolean; /** * Get the height for a specific row. * Returns the measured height if available, otherwise the estimated height. * * @param rowId - The unique identifier of the row. * @returns The height of the row in pixels. */ getHeight(rowId: string): number; /** * Check if a row has been measured. * * @param rowId - The unique identifier of the row. * @returns True if the row has been measured. */ hasMeasurement(rowId: string): boolean; /** * Get the average height of measured rows. * Falls back to the estimated height if no rows have been measured. * * @returns The average row height in pixels. */ getAverageHeight(): number; /** * Calculate the total height for a given number of rows. * * @param rowIds - Array of row IDs in order. * @returns The total height in pixels. */ getTotalHeight(rowIds: string[]): number; /** * Calculate the offset (top position) for a given row index. * * @param rowIds - Array of row IDs in order. * @param index - The index of the target row. * @returns The offset from the top in pixels. */ getOffsetForIndex(rowIds: string[], index: number): number; /** * Calculate which rows are visible given a scroll position and viewport height. * * @param rowIds - Array of row IDs in order. * @param scrollTop - Current scroll position. * @param viewportHeight - Height of the visible area. * @param bufferSize - Number of extra rows to render above/below. * @returns Object with start and end indices of visible rows. */ getVisibleRange(rowIds: string[], scrollTop: number, viewportHeight: number, bufferSize: number): { start: number; end: number; }; /** * Find the row index at a given scroll position. * * @param rowIds - Array of row IDs in order. * @param scrollTop - The scroll position to find. * @returns The index of the row at that position. */ getIndexAtOffset(rowIds: string[], scrollTop: number): number; /** * Clear all cached heights. */ clear(): void; /** * Remove a specific row from the cache. * * @param rowId - The unique identifier of the row to remove. */ remove(rowId: string): void; /** * Get the number of measured rows. */ get size(): number; /** * Update the estimated row height. * * @param height - New estimated height in pixels. */ setEstimatedRowHeight(height: number): void; }