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.esm.js CHANGED
@@ -11319,8 +11319,13 @@ class TrackDataManager {
11319
11319
  * During rapid zoom/pan, this coalesces multiple setLocus() calls into a
11320
11320
  * single data fetch cycle after the interaction settles (100ms quiet period).
11321
11321
  * Abort in-flight requests immediately so they don't race with the eventual fetch.
11322
+ *
11323
+ * @param getViewportWidth Getter that reads the current viewport width when
11324
+ * the timer fires, rather than capturing a stale value at call time. This
11325
+ * prevents the timer from firing with viewportWidth=0 when debouncedLoad
11326
+ * was called before the first render/layout.
11322
11327
  */
11323
- debouncedLoad(managedTracks, locus, viewportWidth) {
11328
+ debouncedLoad(managedTracks, locus, getViewportWidth) {
11324
11329
  // Immediately abort stale in-flight requests so cancelled fetches
11325
11330
  // don't resolve after the debounce fires with a new locus.
11326
11331
  for (const mt of managedTracks) {
@@ -11335,7 +11340,7 @@ class TrackDataManager {
11335
11340
  }
11336
11341
  this.loadDebounceTimer = setTimeout(() => {
11337
11342
  this.loadDebounceTimer = null;
11338
- this.loadAllTracksIfNeeded(managedTracks, locus, viewportWidth);
11343
+ this.loadAllTracksIfNeeded(managedTracks, locus, getViewportWidth());
11339
11344
  }, 100);
11340
11345
  }
11341
11346
  loadAllTracksIfNeeded(managedTracks, locus, viewportWidth) {
@@ -12158,7 +12163,7 @@ class HeadlessGenomeBrowser {
12158
12163
  for (const mt of this.managedTracks) {
12159
12164
  mt.track.setLocus(this._locus);
12160
12165
  }
12161
- this.dataManager.debouncedLoad(this.managedTracks, this._locus, this._viewportWidth);
12166
+ this.dataManager.debouncedLoad(this.managedTracks, this._locus, () => this._viewportWidth);
12162
12167
  this.events.emit(BrowserEvent.LocusChange, { locus: this._locus });
12163
12168
  }
12164
12169
  /**
@@ -14702,14 +14707,16 @@ class GenomeBrowser extends HeadlessGenomeBrowser {
14702
14707
  this.trackRows.set(track, trackRow);
14703
14708
  const id = super.addTrack(track, dataSource, dataSourceConfig, maxTrackHeight, order);
14704
14709
  this._setupTrackRowUI(track);
14705
- // Schedule a post-layout render. The canvas was just appended to the DOM
14706
- // but the browser hasn't reflowed yet, so clientWidth reads 0 and the
14707
- // synchronous render in super.addTrack() (via setLocus) silently skips.
14708
- // rAF fires after layout, ensuring tracks render with correct dimensions.
14710
+ // Schedule a post-layout render + data load. The canvas was just appended
14711
+ // to the DOM but the browser hasn't reflowed yet, so clientWidth reads 0
14712
+ // and both render (BaseTrackCanvas) and data loading (viewportWidth === 0
14713
+ // guard in loadTrackWithDedup) silently skip. rAF fires after layout,
14714
+ // mirroring the ResizeObserver's initial-mount pattern (lines 334-340).
14709
14715
  requestAnimationFrame(() => {
14710
14716
  if (!this.resizeObserver)
14711
14717
  return; // disposed
14712
14718
  this.render();
14719
+ this.loadAllTracksIfNeeded();
14713
14720
  });
14714
14721
  return id;
14715
14722
  }