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.
@@ -9838,8 +9838,13 @@ class TrackDataManager {
9838
9838
  * During rapid zoom/pan, this coalesces multiple setLocus() calls into a
9839
9839
  * single data fetch cycle after the interaction settles (100ms quiet period).
9840
9840
  * Abort in-flight requests immediately so they don't race with the eventual fetch.
9841
+ *
9842
+ * @param getViewportWidth Getter that reads the current viewport width when
9843
+ * the timer fires, rather than capturing a stale value at call time. This
9844
+ * prevents the timer from firing with viewportWidth=0 when debouncedLoad
9845
+ * was called before the first render/layout.
9841
9846
  */
9842
- debouncedLoad(managedTracks, locus, viewportWidth) {
9847
+ debouncedLoad(managedTracks, locus, getViewportWidth) {
9843
9848
  // Immediately abort stale in-flight requests so cancelled fetches
9844
9849
  // don't resolve after the debounce fires with a new locus.
9845
9850
  for (const mt of managedTracks) {
@@ -9854,7 +9859,7 @@ class TrackDataManager {
9854
9859
  }
9855
9860
  this.loadDebounceTimer = setTimeout(() => {
9856
9861
  this.loadDebounceTimer = null;
9857
- this.loadAllTracksIfNeeded(managedTracks, locus, viewportWidth);
9862
+ this.loadAllTracksIfNeeded(managedTracks, locus, getViewportWidth());
9858
9863
  }, 100);
9859
9864
  }
9860
9865
  loadAllTracksIfNeeded(managedTracks, locus, viewportWidth) {
@@ -10677,7 +10682,7 @@ class HeadlessGenomeBrowser {
10677
10682
  for (const mt of this.managedTracks) {
10678
10683
  mt.track.setLocus(this._locus);
10679
10684
  }
10680
- this.dataManager.debouncedLoad(this.managedTracks, this._locus, this._viewportWidth);
10685
+ this.dataManager.debouncedLoad(this.managedTracks, this._locus, () => this._viewportWidth);
10681
10686
  this.events.emit(BrowserEvent.LocusChange, { locus: this._locus });
10682
10687
  }
10683
10688
  /**
@@ -13744,14 +13749,16 @@ class GenomeBrowser extends HeadlessGenomeBrowser {
13744
13749
  this.trackRows.set(track, trackRow);
13745
13750
  const id = super.addTrack(track, dataSource, dataSourceConfig, maxTrackHeight, order);
13746
13751
  this._setupTrackRowUI(track);
13747
- // Schedule a post-layout render. The canvas was just appended to the DOM
13748
- // but the browser hasn't reflowed yet, so clientWidth reads 0 and the
13749
- // synchronous render in super.addTrack() (via setLocus) silently skips.
13750
- // rAF fires after layout, ensuring tracks render with correct dimensions.
13752
+ // Schedule a post-layout render + data load. The canvas was just appended
13753
+ // to the DOM but the browser hasn't reflowed yet, so clientWidth reads 0
13754
+ // and both render (BaseTrackCanvas) and data loading (viewportWidth === 0
13755
+ // guard in loadTrackWithDedup) silently skip. rAF fires after layout,
13756
+ // mirroring the ResizeObserver's initial-mount pattern (lines 334-340).
13751
13757
  requestAnimationFrame(() => {
13752
13758
  if (!this.resizeObserver)
13753
13759
  return; // disposed
13754
13760
  this.render();
13761
+ this.loadAllTracksIfNeeded();
13755
13762
  });
13756
13763
  return id;
13757
13764
  }