@tanstack/virtual-core 3.19.9 → 3.19.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.
- package/dist/cjs/index.cjs +14 -7
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +14 -7
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +29 -7
package/dist/cjs/index.cjs
CHANGED
|
@@ -158,9 +158,12 @@ const scrollWithAdjustments = (offset, {
|
|
|
158
158
|
adjustments = 0,
|
|
159
159
|
behavior
|
|
160
160
|
}, instance) => {
|
|
161
|
-
var _a
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
var _a;
|
|
162
|
+
const { scrollElement, options } = instance;
|
|
163
|
+
const adjustedOffset = offset + adjustments;
|
|
164
|
+
const isRtlElement = options.horizontal && options.isRtl && scrollElement !== null && "ownerDocument" in scrollElement;
|
|
165
|
+
(_a = scrollElement == null ? void 0 : scrollElement.scrollTo) == null ? void 0 : _a.call(scrollElement, {
|
|
166
|
+
[options.horizontal ? "left" : "top"]: isRtlElement ? -adjustedOffset : adjustedOffset,
|
|
164
167
|
behavior
|
|
165
168
|
});
|
|
166
169
|
};
|
|
@@ -909,17 +912,21 @@ class Virtualizer {
|
|
|
909
912
|
this.getMeasurements(),
|
|
910
913
|
this.getSize(),
|
|
911
914
|
this.getScrollOffset(),
|
|
912
|
-
this.options.lanes
|
|
915
|
+
this.options.lanes,
|
|
916
|
+
// scrollOffset is measured in the scroll element and the layout total
|
|
917
|
+
// from the list start, so the list ends scrollMargin further down.
|
|
918
|
+
this._getLayoutTotalSize() + this.options.scrollMargin
|
|
913
919
|
],
|
|
914
|
-
(measurements, outerSize, scrollOffset, lanes) => {
|
|
920
|
+
(measurements, outerSize, scrollOffset, lanes, listEnd) => {
|
|
915
921
|
if (measurements.length === 0 || outerSize === 0) {
|
|
916
922
|
this.range = null;
|
|
917
923
|
return null;
|
|
918
924
|
}
|
|
925
|
+
const maxScrollOffset = Math.max(listEnd - outerSize, 0);
|
|
919
926
|
this.range = calculateRangeImpl(
|
|
920
927
|
measurements,
|
|
921
928
|
outerSize,
|
|
922
|
-
scrollOffset,
|
|
929
|
+
Math.min(scrollOffset, maxScrollOffset),
|
|
923
930
|
lanes,
|
|
924
931
|
// Pass the typed array so binary search + forward-walk can read
|
|
925
932
|
// start/end directly from Float64Array, skipping the Proxy traps.
|
|
@@ -1251,7 +1258,7 @@ class Virtualizer {
|
|
|
1251
1258
|
index = Math.max(0, Math.min(index, this.options.count - 1));
|
|
1252
1259
|
const size = this.getSize();
|
|
1253
1260
|
const scrollOffset = this.getScrollOffset();
|
|
1254
|
-
const item = this.
|
|
1261
|
+
const item = this.getMeasurements()[index];
|
|
1255
1262
|
if (!item) return;
|
|
1256
1263
|
if (align === "auto") {
|
|
1257
1264
|
if (item.end >= scrollOffset + size - this.options.scrollPaddingEnd) {
|