* Setup ResizeObserver to detect height changes in rendered items
()
| 396 | * Setup ResizeObserver to detect height changes in rendered items |
| 397 | */ |
| 398 | private setupResizeObserver(): void { |
| 399 | this.resizeObserver = new ResizeObserver((entries) => { |
| 400 | // Collect indices that need remeasurement |
| 401 | for (const entry of entries) { |
| 402 | const element = entry.target as HTMLElement; |
| 403 | const index = parseInt(element.dataset.virtualIndex || "-1", 10); |
| 404 | |
| 405 | if (index >= 0 && index < this.items.length) { |
| 406 | this.pendingMeasurements.add(index); |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | // Debounce the actual measurement update |
| 411 | if (this.measurementRAF === null) { |
| 412 | this.measurementRAF = window.requestAnimationFrame(() => { |
| 413 | this.processPendingMeasurements(); |
| 414 | this.measurementRAF = null; |
| 415 | }); |
| 416 | } |
| 417 | }); |
| 418 | } |
| 419 | |
| 420 | /** |
| 421 | * Measure items and update position cache if heights changed |
no test coverage detected