@tanstack/virtual-core 3.19.5 → 3.19.7
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 +8 -13
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +8 -13
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +17 -13
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -74,8 +74,8 @@ export interface Rect {
|
|
|
74
74
|
//
|
|
75
75
|
|
|
76
76
|
const getRect = (element: HTMLElement): Rect => {
|
|
77
|
-
const {
|
|
78
|
-
return { width:
|
|
77
|
+
const { clientWidth, clientHeight } = element
|
|
78
|
+
return { width: clientWidth, height: clientHeight }
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
// Animation frames for `useAnimationFrameWithResizeObserver`, requested from
|
|
@@ -141,16 +141,8 @@ export const observeElementRect = <T extends Element>(
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
const frames = createFrameQueue(targetWindow)
|
|
144
|
-
const observer = new targetWindow.ResizeObserver((
|
|
144
|
+
const observer = new targetWindow.ResizeObserver(() => {
|
|
145
145
|
const run = () => {
|
|
146
|
-
const entry = entries[0]
|
|
147
|
-
if (entry?.borderBoxSize) {
|
|
148
|
-
const box = entry.borderBoxSize[0]
|
|
149
|
-
if (box) {
|
|
150
|
-
handler({ width: box.inlineSize, height: box.blockSize })
|
|
151
|
-
return
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
146
|
handler(getRect(element as unknown as HTMLElement))
|
|
155
147
|
}
|
|
156
148
|
|
|
@@ -159,7 +151,7 @@ export const observeElementRect = <T extends Element>(
|
|
|
159
151
|
: run()
|
|
160
152
|
})
|
|
161
153
|
|
|
162
|
-
observer.observe(element, { box: '
|
|
154
|
+
observer.observe(element, { box: 'content-box' })
|
|
163
155
|
|
|
164
156
|
return () => {
|
|
165
157
|
observer.unobserve(element)
|
|
@@ -591,6 +583,9 @@ export class Virtualizer<
|
|
|
591
583
|
}
|
|
592
584
|
this._flushHoldIfReady(true)
|
|
593
585
|
this._writeAwaitingCommand()
|
|
586
|
+
// A clamped write the touch held back; a command written above has
|
|
587
|
+
// cleared it.
|
|
588
|
+
this._retryClampedAdjustment()
|
|
594
589
|
},
|
|
595
590
|
})
|
|
596
591
|
// The last position the scroll handler was given, in the element's own
|
|
@@ -1298,11 +1293,14 @@ export class Virtualizer<
|
|
|
1298
1293
|
// may follow at all), and from `_willUpdate` for consumers that size it
|
|
1299
1294
|
// during an asynchronous render. Both the clamped read-back and the
|
|
1300
1295
|
// absence of one leave `_clampedAdjustment` set, so timing does not matter.
|
|
1296
|
+
// While the element cannot take a write (`_canWriteScroll`) the record is
|
|
1297
|
+
// kept for the next opportunity, the latest being the tail closing.
|
|
1301
1298
|
private _retryClampedAdjustment = () => {
|
|
1302
1299
|
if (
|
|
1303
1300
|
this._clampedAdjustment === null ||
|
|
1304
1301
|
!this.scrollElement ||
|
|
1305
|
-
!this.options.enabled
|
|
1302
|
+
!this.options.enabled ||
|
|
1303
|
+
!this._canWriteScroll()
|
|
1306
1304
|
) {
|
|
1307
1305
|
return
|
|
1308
1306
|
}
|
|
@@ -2437,6 +2435,12 @@ export class Virtualizer<
|
|
|
2437
2435
|
behavior: ScrollBehavior,
|
|
2438
2436
|
kind: 'absolute' | 'relative',
|
|
2439
2437
|
) {
|
|
2438
|
+
// A new explicit command supersedes layout-driven work queued before it.
|
|
2439
|
+
// Clear both before any iOS deferral so a later commit/retry cannot
|
|
2440
|
+
// overwrite the user's newer scroll intent.
|
|
2441
|
+
this.pendingScrollAnchor = null
|
|
2442
|
+
this._clampedAdjustment = null
|
|
2443
|
+
|
|
2440
2444
|
const tail = this._iosGesture.tail()
|
|
2441
2445
|
if (kind === 'absolute' && tail !== null) {
|
|
2442
2446
|
if (tail === 'fling' && iosMomentumOverridesWrites()) {
|