@tanstack/virtual-core 3.19.14 → 3.19.15
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/cjs/index.cjs +25 -7
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +2 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +25 -7
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +42 -7
package/dist/cjs/index.cjs
CHANGED
|
@@ -260,6 +260,7 @@ class Virtualizer {
|
|
|
260
260
|
this._clampedAdjustment = null;
|
|
261
261
|
this.elementsCache = /* @__PURE__ */ new Map();
|
|
262
262
|
this._resizeBatch = null;
|
|
263
|
+
this._dropQueued = false;
|
|
263
264
|
this.now = () => {
|
|
264
265
|
var _a, _b, _c;
|
|
265
266
|
return ((_c = (_b = (_a = this.targetWindow) == null ? void 0 : _a.performance) == null ? void 0 : _b.now) == null ? void 0 : _c.call(_b)) ?? Date.now();
|
|
@@ -1073,14 +1074,24 @@ class Virtualizer {
|
|
|
1073
1074
|
}
|
|
1074
1075
|
return true;
|
|
1075
1076
|
};
|
|
1077
|
+
this.dropDisconnected = () => {
|
|
1078
|
+
this.elementsCache.forEach((cached, key) => {
|
|
1079
|
+
if (!cached.isConnected) {
|
|
1080
|
+
this.observer.unobserve(cached);
|
|
1081
|
+
this.elementsCache.delete(key);
|
|
1082
|
+
}
|
|
1083
|
+
});
|
|
1084
|
+
};
|
|
1076
1085
|
this.measureElement = (node) => {
|
|
1077
1086
|
if (!node) {
|
|
1078
|
-
this.
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1087
|
+
this.dropDisconnected();
|
|
1088
|
+
if (!this._dropQueued) {
|
|
1089
|
+
this._dropQueued = true;
|
|
1090
|
+
queueMicrotask(() => {
|
|
1091
|
+
this._dropQueued = false;
|
|
1092
|
+
this.dropDisconnected();
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1084
1095
|
return;
|
|
1085
1096
|
}
|
|
1086
1097
|
const index = this.indexFromElement(node);
|
|
@@ -1630,7 +1641,8 @@ class Virtualizer {
|
|
|
1630
1641
|
// before the command (below). One held for a touch or a bounce is not
|
|
1631
1642
|
// dropped by a command: the write lands the element `_holdOffset` short
|
|
1632
1643
|
// of the target, under the rows exposed shifted by the same amount, and
|
|
1633
|
-
// the flush moves both together once a write is possible.
|
|
1644
|
+
// the flush moves both together once a write is possible. Unless the
|
|
1645
|
+
// target is less than the hold (below).
|
|
1634
1646
|
//
|
|
1635
1647
|
// An index or end target that is already at its offset starts a smooth
|
|
1636
1648
|
// scroll as landed; an offset target never does, so its first scroll
|
|
@@ -1675,6 +1687,12 @@ class Virtualizer {
|
|
|
1675
1687
|
}
|
|
1676
1688
|
this._iosGesture.end();
|
|
1677
1689
|
}
|
|
1690
|
+
if (offset < this._holdOffset && this._canWriteScroll()) {
|
|
1691
|
+
this.scrollState = null;
|
|
1692
|
+
this._flushHoldIfReady(true);
|
|
1693
|
+
this._clampedAdjustment = null;
|
|
1694
|
+
offset = Math.min(offset, Math.max(this.getMaxScrollOffset(), 0));
|
|
1695
|
+
}
|
|
1678
1696
|
this.scrollState = {
|
|
1679
1697
|
...target,
|
|
1680
1698
|
startedAt: this.now(),
|