@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.
@@ -169,7 +169,7 @@ export declare class Virtualizer<TScrollElement extends Element | Window, TItemE
169
169
  startIndex: number;
170
170
  endIndex: number;
171
171
  } | null;
172
- updateDeps(newDeps: [VirtualItem[], number, number, number]): void;
172
+ updateDeps(newDeps: [VirtualItem[], number, number, number, number]): void;
173
173
  };
174
174
  getVirtualIndexes: {
175
175
  (): number[];
@@ -169,7 +169,7 @@ export declare class Virtualizer<TScrollElement extends Element | Window, TItemE
169
169
  startIndex: number;
170
170
  endIndex: number;
171
171
  } | null;
172
- updateDeps(newDeps: [VirtualItem[], number, number, number]): void;
172
+ updateDeps(newDeps: [VirtualItem[], number, number, number, number]): void;
173
173
  };
174
174
  getVirtualIndexes: {
175
175
  (): number[];
package/dist/esm/index.js CHANGED
@@ -157,9 +157,12 @@ const scrollWithAdjustments = (offset, {
157
157
  adjustments = 0,
158
158
  behavior
159
159
  }, instance) => {
160
- var _a, _b;
161
- (_b = (_a = instance.scrollElement) == null ? void 0 : _a.scrollTo) == null ? void 0 : _b.call(_a, {
162
- [instance.options.horizontal ? "left" : "top"]: offset + adjustments,
160
+ var _a;
161
+ const { scrollElement, options } = instance;
162
+ const adjustedOffset = offset + adjustments;
163
+ const isRtlElement = options.horizontal && options.isRtl && scrollElement !== null && "ownerDocument" in scrollElement;
164
+ (_a = scrollElement == null ? void 0 : scrollElement.scrollTo) == null ? void 0 : _a.call(scrollElement, {
165
+ [options.horizontal ? "left" : "top"]: isRtlElement ? -adjustedOffset : adjustedOffset,
163
166
  behavior
164
167
  });
165
168
  };
@@ -908,17 +911,21 @@ class Virtualizer {
908
911
  this.getMeasurements(),
909
912
  this.getSize(),
910
913
  this.getScrollOffset(),
911
- this.options.lanes
914
+ this.options.lanes,
915
+ // scrollOffset is measured in the scroll element and the layout total
916
+ // from the list start, so the list ends scrollMargin further down.
917
+ this._getLayoutTotalSize() + this.options.scrollMargin
912
918
  ],
913
- (measurements, outerSize, scrollOffset, lanes) => {
919
+ (measurements, outerSize, scrollOffset, lanes, listEnd) => {
914
920
  if (measurements.length === 0 || outerSize === 0) {
915
921
  this.range = null;
916
922
  return null;
917
923
  }
924
+ const maxScrollOffset = Math.max(listEnd - outerSize, 0);
918
925
  this.range = calculateRangeImpl(
919
926
  measurements,
920
927
  outerSize,
921
- scrollOffset,
928
+ Math.min(scrollOffset, maxScrollOffset),
922
929
  lanes,
923
930
  // Pass the typed array so binary search + forward-walk can read
924
931
  // start/end directly from Float64Array, skipping the Proxy traps.
@@ -1250,7 +1257,7 @@ class Virtualizer {
1250
1257
  index = Math.max(0, Math.min(index, this.options.count - 1));
1251
1258
  const size = this.getSize();
1252
1259
  const scrollOffset = this.getScrollOffset();
1253
- const item = this.measurementsCache[index];
1260
+ const item = this.getMeasurements()[index];
1254
1261
  if (!item) return;
1255
1262
  if (align === "auto") {
1256
1263
  if (item.end >= scrollOffset + size - this.options.scrollPaddingEnd) {