@tanstack/virtual-core 3.19.7 → 3.19.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/virtual-core",
3
- "version": "3.19.7",
3
+ "version": "3.19.8",
4
4
  "description": "Headless UI for virtualizing scrollable elements in TS/JS + Frameworks",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -2269,8 +2269,16 @@ export class Virtualizer<
2269
2269
  }
2270
2270
 
2271
2271
  private getVirtualDistanceFromEnd = () => {
2272
+ // `_getLayoutTotalSize()` measures the sizer, which starts `scrollMargin`
2273
+ // into the scroll content, while `getScrollOffset()` is measured from the
2274
+ // top of that content. Lift the total into the element's space before
2275
+ // subtracting, or the viewport reads `scrollMargin` px closer to the end
2276
+ // than it is and `getDistanceFromEnd()` disagrees by that much.
2272
2277
  return Math.max(
2273
- this._getLayoutTotalSize() - this.getSize() - this.getScrollOffset(),
2278
+ this._getLayoutTotalSize() +
2279
+ this.options.scrollMargin -
2280
+ this.getSize() -
2281
+ this.getScrollOffset(),
2274
2282
  0,
2275
2283
  )
2276
2284
  }