@mindfiredigital/pivothead
Version:
PivotHead is a powerful and flexible library for creating interactive pivot tables in JavaScript applications. It provides a core engine for data manipulation and, in the future, will be compatible with wrappers for React, Vue, Svelte, and Angular, making
120 lines • 3.07 kB
TypeScript
import type { VirtualScrollConfig, VisibleRange, DataRecord } from '../types/interfaces';
export type { VirtualScrollConfig, VisibleRange };
/**
* VirtualScrollManager - Efficient virtual scrolling implementation
*
* Renders only visible rows from a large dataset, dramatically improving
* performance for datasets with thousands or millions of rows.
*
* @example
* ```typescript
* const scroller = new VirtualScrollManager({
* container: document.getElementById('table-container'),
* data: largeDataset,
* rowHeight: 40,
* bufferSize: 10,
* renderRow: (item, index) => createTableRow(item, index)
* });
* scroller.render();
* ```
*/
export declare class VirtualScrollManager {
private container;
private data;
private rowHeight;
private bufferSize;
private renderRow;
private renderHeader?;
private onVisibleRangeChange?;
private onDragDrop?;
private scrollTop;
private visibleStart;
private visibleEnd;
private containerHeight;
private wrapper;
private spacer;
private content;
private resizeObserver;
private scrollRAF;
constructor(config: VirtualScrollConfig);
/**
* Initialize the virtual scrolling structure
* @private
*/
private init;
/**
* Handle scroll events with requestAnimationFrame throttling
* @private
*/
private handleScroll;
/**
* Process scroll event
* @private
*/
private onScroll;
/**
* Calculate the range of visible rows
* @returns Object with start and end indices
*/
getVisibleRange(): VisibleRange;
/**
* Render the visible rows
*/
render(): void;
/**
* Add drag-and-drop support to a row
* @private
*/
private addDragDropSupport;
/**
* Update the dataset
* @param data New dataset
*/
setData(data: DataRecord[]): void;
/**
* Update row height
* @param height New row height in pixels
*/
updateRowHeight(height: number): void;
/**
* Scroll to a specific row index
* @param index Row index to scroll to
*/
scrollToIndex(index: number): void;
/**
* Scroll to the top
*/
scrollToTop(): void;
/**
* Mount the virtual scroller to a parent element
* @param parentElement Parent element to mount to
*/
mount(parentElement: HTMLElement): void;
/**
* Refresh the current view
*/
refresh(): void;
/**
* Get the current scroll position
* @returns Current scroll top position
*/
getScrollTop(): number;
/**
* Get the total number of rows
* @returns Total row count
*/
getRowCount(): number;
/**
* Get the current visible start and end indices
* @returns Object with visibleStart and visibleEnd
*/
getVisibleIndices(): {
visibleStart: number;
visibleEnd: number;
};
/**
* Clean up resources and remove event listeners
*/
destroy(): void;
}
//# sourceMappingURL=VirtualScrollManager.d.ts.map