MCPcopy Create free account
hub / github.com/callumalpass/tasknotes / setupResizeObserver

Method setupResizeObserver

src/utils/VirtualScroller.ts:398–418  ·  view source on GitHub ↗

* Setup ResizeObserver to detect height changes in rendered items

()

Source from the content-addressed store, hash-verified

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

Callers 1

constructorMethod · 0.95

Calls 1

Tested by

no test coverage detected