(options: VirtualScrollerOptions<T>)
| 99 | private invalidatedKeys = new Set<string>(); |
| 100 | |
| 101 | constructor(options: VirtualScrollerOptions<T>) { |
| 102 | this.container = options.container; |
| 103 | this.items = options.items; |
| 104 | this.estimatedHeight = options.itemHeight ?? 0; // Will be calculated if not provided |
| 105 | this.overscan = options.overscan ?? 5; |
| 106 | this.renderItem = options.renderItem; |
| 107 | this.getItemKey = options.getItemKey ?? ((item, index) => String(index)); |
| 108 | |
| 109 | this.setupDOM(); |
| 110 | this.attachScrollListener(); |
| 111 | this.setupResizeObserver(); |
| 112 | |
| 113 | // If no itemHeight provided, calculate from sample |
| 114 | if (!options.itemHeight && this.items.length > 0) { |
| 115 | this.calculateEstimatedHeight(); |
| 116 | } |
| 117 | |
| 118 | this.rebuildPositionCache(); |
| 119 | this.updateVisibleRange(); |
| 120 | } |
| 121 | |
| 122 | private setupDOM(): void { |
| 123 | // Clear existing content |
nothing calls this directly
no test coverage detected