@tanstack/virtual-core 3.19.5 → 3.19.7

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/esm/index.js CHANGED
@@ -4,8 +4,8 @@ import { flingCaught, externalRetiresCommand, flingSpedUp, classifyScrollEvent }
4
4
  import { IosGesture, isIOSWebKit, iosMomentumOverridesWrites } from "./ios-gesture.js";
5
5
  import { _resetIOSDetectionForTests } from "./ios-gesture.js";
6
6
  const getRect = (element) => {
7
- const { offsetWidth, offsetHeight } = element;
8
- return { width: offsetWidth, height: offsetHeight };
7
+ const { clientWidth, clientHeight } = element;
8
+ return { width: clientWidth, height: clientHeight };
9
9
  };
10
10
  const createFrameQueue = (targetWindow) => {
11
11
  const ids = /* @__PURE__ */ new Set();
@@ -54,21 +54,13 @@ const observeElementRect = (instance, cb) => {
54
54
  };
55
55
  }
56
56
  const frames = createFrameQueue(targetWindow);
57
- const observer = new targetWindow.ResizeObserver((entries) => {
57
+ const observer = new targetWindow.ResizeObserver(() => {
58
58
  const run = () => {
59
- const entry = entries[0];
60
- if (entry == null ? void 0 : entry.borderBoxSize) {
61
- const box = entry.borderBoxSize[0];
62
- if (box) {
63
- handler({ width: box.inlineSize, height: box.blockSize });
64
- return;
65
- }
66
- }
67
59
  handler(getRect(element));
68
60
  };
69
61
  instance.options.useAnimationFrameWithResizeObserver ? frames.schedule(run) : run();
70
62
  });
71
- observer.observe(element, { box: "border-box" });
63
+ observer.observe(element, { box: "content-box" });
72
64
  return () => {
73
65
  observer.unobserve(element);
74
66
  frames.cancel();
@@ -247,6 +239,7 @@ class Virtualizer {
247
239
  }
248
240
  this._flushHoldIfReady(true);
249
241
  this._writeAwaitingCommand();
242
+ this._retryClampedAdjustment();
250
243
  }
251
244
  });
252
245
  this._lastElementOffset = null;
@@ -625,7 +618,7 @@ class Virtualizer {
625
618
  });
626
619
  };
627
620
  this._retryClampedAdjustment = () => {
628
- if (this._clampedAdjustment === null || !this.scrollElement || !this.options.enabled) {
621
+ if (this._clampedAdjustment === null || !this.scrollElement || !this.options.enabled || !this._canWriteScroll()) {
629
622
  return;
630
623
  }
631
624
  const { target, maxAtWrite } = this._clampedAdjustment;
@@ -1493,6 +1486,8 @@ class Virtualizer {
1493
1486
  // scroll as landed; an offset target never does, so its first scroll
1494
1487
  // event is read as the user's (see the scroll handler in `_willUpdate`).
1495
1488
  _startScroll(target, offset, behavior, kind) {
1489
+ this.pendingScrollAnchor = null;
1490
+ this._clampedAdjustment = null;
1496
1491
  const tail = this._iosGesture.tail();
1497
1492
  if (kind === "absolute" && tail !== null) {
1498
1493
  if (tail === "fling" && iosMomentumOverridesWrites()) {