@tanstack/virtual-core
Advanced tools
@@ -415,2 +415,5 @@ "use strict"; | ||
| this.options.observeElementOffset(this, (offset, isScrolling) => { | ||
| if (isScrolling && this._intendedScrollOffset === null && offset === this.scrollOffset) { | ||
| return; | ||
| } | ||
| if (this._intendedScrollOffset !== null && Math.abs(offset - this._intendedScrollOffset) < 1.5) { | ||
@@ -1109,2 +1112,6 @@ offset = this._intendedScrollOffset; | ||
| }); | ||
| if (this.scrollOffset !== null) { | ||
| this.scrollOffset += this.scrollAdjustments; | ||
| this.scrollAdjustments = 0; | ||
| } | ||
| } | ||
@@ -1111,0 +1118,0 @@ } |
@@ -413,2 +413,5 @@ import { createLazyMeasurementsView } from "./lazy-measurements.js"; | ||
| this.options.observeElementOffset(this, (offset, isScrolling) => { | ||
| if (isScrolling && this._intendedScrollOffset === null && offset === this.scrollOffset) { | ||
| return; | ||
| } | ||
| if (this._intendedScrollOffset !== null && Math.abs(offset - this._intendedScrollOffset) < 1.5) { | ||
@@ -1107,2 +1110,6 @@ offset = this._intendedScrollOffset; | ||
| }); | ||
| if (this.scrollOffset !== null) { | ||
| this.scrollOffset += this.scrollAdjustments; | ||
| this.scrollAdjustments = 0; | ||
| } | ||
| } | ||
@@ -1109,0 +1116,0 @@ } |
+1
-1
| { | ||
| "name": "@tanstack/virtual-core", | ||
| "version": "3.17.1", | ||
| "version": "3.17.2", | ||
| "description": "Headless UI for virtualizing scrollable elements in TS/JS + Frameworks", | ||
@@ -5,0 +5,0 @@ "author": "Tanner Linsley", |
+28
-0
@@ -695,2 +695,15 @@ import { createLazyMeasurementsView } from './lazy-measurements' | ||
| }) | ||
| // Eagerly carry the intended target in `scrollOffset` so callers that | ||
| // read it before the next scroll event — notably the next `resizeItem` | ||
| // tick's `getVirtualDistanceFromEnd()` / `wasAtEnd` check — see the | ||
| // post-adjustment position even when the DOM `scrollTop` write was | ||
| // clamped because the consumer hasn't grown the sizer yet (`notify()` | ||
| // runs after this in `resizeItem`). Same idea as the eager | ||
| // `scrollOffset` adjustment for prepend in `setOptions` (#1176). The | ||
| // adjustment is now baked into `scrollOffset`, so zero | ||
| // `scrollAdjustments` to keep their sum invariant. | ||
| if (this.scrollOffset !== null) { | ||
| this.scrollOffset += this.scrollAdjustments | ||
| this.scrollAdjustments = 0 | ||
| } | ||
| } | ||
@@ -776,2 +789,17 @@ } | ||
| this.options.observeElementOffset(this, (offset, isScrolling) => { | ||
| // A scroll event that reports movement but lands on the offset we | ||
| // already hold — and isn't a self-write read-back — is a spurious | ||
| // no-op re-emit that Safari/Firefox fire after a re-render's layout | ||
| // (Chrome doesn't). Treating it as scrolling re-arms `isScrolling`, | ||
| // which forces a render that triggers another such event: an | ||
| // infinite re-render loop. Ignore it. (Self-writes are handled by | ||
| // the `_intendedScrollOffset` reconciliation just below.) | ||
| if ( | ||
| isScrolling && | ||
| this._intendedScrollOffset === null && | ||
| offset === this.scrollOffset | ||
| ) { | ||
| return | ||
| } | ||
| // If this scroll event looks like the browser's read-back of a | ||
@@ -778,0 +806,0 @@ // value we just wrote, prefer our intended (sub-pixel-accurate) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
383877
1.42%4808
0.86%