loom-browser 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/loom.js CHANGED
@@ -11321,8 +11321,13 @@
11321
11321
  * During rapid zoom/pan, this coalesces multiple setLocus() calls into a
11322
11322
  * single data fetch cycle after the interaction settles (100ms quiet period).
11323
11323
  * Abort in-flight requests immediately so they don't race with the eventual fetch.
11324
+ *
11325
+ * @param getViewportWidth Getter that reads the current viewport width when
11326
+ * the timer fires, rather than capturing a stale value at call time. This
11327
+ * prevents the timer from firing with viewportWidth=0 when debouncedLoad
11328
+ * was called before the first render/layout.
11324
11329
  */
11325
- debouncedLoad(managedTracks, locus, viewportWidth) {
11330
+ debouncedLoad(managedTracks, locus, getViewportWidth) {
11326
11331
  // Immediately abort stale in-flight requests so cancelled fetches
11327
11332
  // don't resolve after the debounce fires with a new locus.
11328
11333
  for (const mt of managedTracks) {
@@ -11337,7 +11342,7 @@
11337
11342
  }
11338
11343
  this.loadDebounceTimer = setTimeout(() => {
11339
11344
  this.loadDebounceTimer = null;
11340
- this.loadAllTracksIfNeeded(managedTracks, locus, viewportWidth);
11345
+ this.loadAllTracksIfNeeded(managedTracks, locus, getViewportWidth());
11341
11346
  }, 100);
11342
11347
  }
11343
11348
  loadAllTracksIfNeeded(managedTracks, locus, viewportWidth) {
@@ -12160,7 +12165,7 @@
12160
12165
  for (const mt of this.managedTracks) {
12161
12166
  mt.track.setLocus(this._locus);
12162
12167
  }
12163
- this.dataManager.debouncedLoad(this.managedTracks, this._locus, this._viewportWidth);
12168
+ this.dataManager.debouncedLoad(this.managedTracks, this._locus, () => this._viewportWidth);
12164
12169
  this.events.emit(BrowserEvent.LocusChange, { locus: this._locus });
12165
12170
  }
12166
12171
  /**
@@ -14704,14 +14709,16 @@
14704
14709
  this.trackRows.set(track, trackRow);
14705
14710
  const id = super.addTrack(track, dataSource, dataSourceConfig, maxTrackHeight, order);
14706
14711
  this._setupTrackRowUI(track);
14707
- // Schedule a post-layout render. The canvas was just appended to the DOM
14708
- // but the browser hasn't reflowed yet, so clientWidth reads 0 and the
14709
- // synchronous render in super.addTrack() (via setLocus) silently skips.
14710
- // rAF fires after layout, ensuring tracks render with correct dimensions.
14712
+ // Schedule a post-layout render + data load. The canvas was just appended
14713
+ // to the DOM but the browser hasn't reflowed yet, so clientWidth reads 0
14714
+ // and both render (BaseTrackCanvas) and data loading (viewportWidth === 0
14715
+ // guard in loadTrackWithDedup) silently skip. rAF fires after layout,
14716
+ // mirroring the ResizeObserver's initial-mount pattern (lines 334-340).
14711
14717
  requestAnimationFrame(() => {
14712
14718
  if (!this.resizeObserver)
14713
14719
  return; // disposed
14714
14720
  this.render();
14721
+ this.loadAllTracksIfNeeded();
14715
14722
  });
14716
14723
  return id;
14717
14724
  }