@shival99/z-ui 2.0.75 → 2.0.76

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.
@@ -6725,6 +6725,7 @@ class ZTableComponent {
6725
6725
  elementScroll(offset, options, instance);
6726
6726
  },
6727
6727
  measureElement: (element) => element.getBoundingClientRect().height,
6728
+ useAnimationFrameWithResizeObserver: true,
6728
6729
  overscan: virtualConfig.overscan ?? Z_DEFAULT_VIRTUAL_OVERSCAN,
6729
6730
  initialOffset: virtualConfig.initialOffset ?? 0,
6730
6731
  ...pickDefined(virtualConfig, [
@@ -6737,14 +6738,22 @@ class ZTableComponent {
6737
6738
  ]),
6738
6739
  };
6739
6740
  });
6740
- _measureVirtualItems = effect(() => {
6741
- if (!this.dynamicSize() || this.virtualizer.isScrolling()) {
6741
+ _measureVirtualItems = effect(onCleanup => {
6742
+ if (!this.dynamicSize()) {
6742
6743
  return;
6743
6744
  }
6744
6745
  const elements = this.virtualRowElements();
6745
- for (const el of elements) {
6746
- this.virtualizer.measureElement(el.nativeElement);
6746
+ const view = this._document.defaultView;
6747
+ if (!view) {
6748
+ return;
6747
6749
  }
6750
+ // Gom phép đo vào frame kế tiếp để tránh cập nhật vị trí nhiều lần trong cùng một frame scroll.
6751
+ const frameId = view.requestAnimationFrame(() => {
6752
+ for (const el of elements) {
6753
+ this.virtualizer.measureElement(el.nativeElement);
6754
+ }
6755
+ });
6756
+ onCleanup(() => view.cancelAnimationFrame(frameId));
6748
6757
  }, ...(ngDevMode ? [{ debugName: "_measureVirtualItems" }] : []));
6749
6758
  _rowDragAutoScroll = effect(onCleanup => {
6750
6759
  const scrollbar = this.tbodyScrollbar();