@shival99/z-ui 2.0.81 → 2.0.82

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.
@@ -6701,8 +6701,7 @@ class ZTableComponent {
6701
6701
  },
6702
6702
  ];
6703
6703
  _bulkBarExitDuration = 140;
6704
- /** Stable identity key per virtual index (row/group id, not array index) so cached measured
6705
- * heights follow row identity — prevents height jitter when scrolling fast. */
6704
+ /** Stable identity key per virtual index (row/group id, not array index) prevents height jitter on fast scroll. */
6706
6705
  _virtualItemKeys = computed(() => {
6707
6706
  if (!this.isVirtual()) {
6708
6707
  return [];
@@ -6717,9 +6716,7 @@ class ZTableComponent {
6717
6716
  }
6718
6717
  return Array.from({ length: this._virtualGroupCount() }, (_, index) => index);
6719
6718
  }, ...(ngDevMode ? [{ debugName: "_virtualItemKeys" }] : []));
6720
- /** Estimate height learned from real rendered rows (dynamicSize); `virtual.size` is the fallback
6721
- * until a row is measured. Lets not-yet-measured rows estimate close to reality, reducing layout
6722
- * shift. Plain field (non-reactive) so updating it won't rebuild the virtualizer. */
6719
+ /** Estimate height learned from rendered rows (dynamicSize); falls back to `virtual.size`. Reduces layout shift. */
6723
6720
  _dynamicEstimateHeight = null;
6724
6721
  /** Virtualizer instance — operates on groups rather than individual rows */
6725
6722
  virtualizer = injectVirtualizer(() => {
@@ -6760,7 +6757,6 @@ class ZTableComponent {
6760
6757
  elementScroll(offset, options, instance);
6761
6758
  },
6762
6759
  measureElement: (element) => element.getBoundingClientRect().height,
6763
- useAnimationFrameWithResizeObserver: true,
6764
6760
  overscan: virtualConfig.overscan ?? Z_DEFAULT_VIRTUAL_OVERSCAN,
6765
6761
  initialOffset: virtualConfig.initialOffset ?? 0,
6766
6762
  ...pickDefined(virtualConfig, [
@@ -6773,33 +6769,22 @@ class ZTableComponent {
6773
6769
  ]),
6774
6770
  };
6775
6771
  });
6776
- _measureVirtualItems = effect(onCleanup => {
6772
+ _measureVirtualItems = effect(() => {
6777
6773
  if (!this.dynamicSize()) {
6778
6774
  return;
6779
6775
  }
6776
+ // Measure synchronously (no rAF) so sizes are corrected before paint — avoids first-scroll jitter.
6780
6777
  const elements = this.virtualRowElements();
6781
- const view = this._document.defaultView;
6782
- if (!view) {
6783
- return;
6784
- }
6785
- // Only learn the estimate until it's locked; afterwards just measure.
6786
6778
  const needsEstimate = this._dynamicEstimateHeight === null;
6787
- // Batch measurements into the next frame to avoid repositioning multiple times per scroll frame.
6788
- const frameId = view.requestAnimationFrame(() => {
6789
- // measureElement() does its own getBoundingClientRect internally — do NOT read the rect again
6790
- // here, the second read would force an extra reflow per row and tank scroll performance.
6791
- for (const el of elements) {
6792
- this.virtualizer.measureElement(el.nativeElement);
6793
- }
6794
- if (needsEstimate) {
6795
- this._learnDynamicEstimate();
6796
- }
6797
- });
6798
- onCleanup(() => view.cancelAnimationFrame(frameId));
6779
+ for (const el of elements) {
6780
+ this.virtualizer.measureElement(el.nativeElement);
6781
+ }
6782
+ // Defer learning to a microtask it calls virtualizer.measure() (writes signals).
6783
+ if (needsEstimate) {
6784
+ queueMicrotask(() => this._learnDynamicEstimate());
6785
+ }
6799
6786
  }, ...(ngDevMode ? [{ debugName: "_measureVirtualItems" }] : []));
6800
- /** Learn estimate height from already-measured rows. Reads sizes from the virtualizer's measurement
6801
- * cache (no DOM reads / reflow). Locks ONCE so the estimate doesn't jump every scroll frame; each
6802
- * row is still measured exactly on render. Re-flows via virtualizer.measure(). */
6787
+ /** Learn estimate height from measured rows (reads the measurement cache, no reflow). Locks once. */
6803
6788
  _learnDynamicEstimate() {
6804
6789
  if (this._dynamicEstimateHeight !== null) {
6805
6790
  return;
@@ -6808,7 +6793,7 @@ class ZTableComponent {
6808
6793
  let measuredSum = 0;
6809
6794
  let measuredCount = 0;
6810
6795
  for (const item of this.virtualizer.getVirtualItems()) {
6811
- // Skip items still sitting at the default estimate — only real measured rows inform the average.
6796
+ // Skip items still at the default estimate — only real measured rows inform the average.
6812
6797
  if (item.size > 0 && item.size !== rowHeight) {
6813
6798
  measuredSum += item.size;
6814
6799
  measuredCount++;