From 7f5110b714978f327569947c6a0b6c0210b8f27c Mon Sep 17 00:00:00 2001 From: Damian Pieczynski Date: Thu, 26 Nov 2026 09:27:08 +0100 Subject: [PATCH 1/4] fix(virtual-core): write a prepend's anchor two frames later under WebKit wheel input WebKit can drop a scrollTop write made while wheel input drives the scroll, so a prepend's anchor write lost that way throws the reader by the whole prepend (#1398). Hold the anchor for two frames and write it from the second. Size corrections are written as before. Measured with the issue's repro in Playwright WebKit 26.0: no jump in 18 runs, against about 1 run in 4 before. Real Safari and trackpad momentum are not measured. --- .changeset/webkit-wheel-prepend-anchor.md | 5 + packages/virtual-core/src/index.ts | 65 +++++++++- packages/virtual-core/src/ios-gesture.ts | 12 ++ .../virtual-core/tests/wheel-anchor.test.ts | 121 ++++++++++++++++++ 4 files changed, 197 insertions(+), 6 deletions(-) create mode 100644 .changeset/webkit-wheel-prepend-anchor.md create mode 100644 packages/virtual-core/tests/wheel-anchor.test.ts diff --git a/.changeset/webkit-wheel-prepend-anchor.md b/.changeset/webkit-wheel-prepend-anchor.md new file mode 100644 index 000000000..93e983581 --- /dev/null +++ b/.changeset/webkit-wheel-prepend-anchor.md @@ -0,0 +1,5 @@ +--- +'@tanstack/virtual-core': patch +--- + +Fix an end-anchored list losing the reader's place in WebKit when rows are prepended during wheel or trackpad scrolling. The anchor write is now made two frames later, where WebKit keeps it. diff --git a/packages/virtual-core/src/index.ts b/packages/virtual-core/src/index.ts index 4bd3531db..7a641695e 100644 --- a/packages/virtual-core/src/index.ts +++ b/packages/virtual-core/src/index.ts @@ -9,7 +9,12 @@ import { flingCaught, flingSpedUp, } from './scroll-classifier' -import { IosGesture, isIOSWebKit, momentumOverridesWrites } from './ios-gesture' +import { + IosGesture, + isIOSWebKit, + isWebKit, + momentumOverridesWrites, +} from './ios-gesture' import type { ScrollPhase, ScrollSample } from './scroll-classifier' export { _resetIOSDetectionForTests } from './ios-gesture' @@ -540,6 +545,10 @@ export class Virtualizer< // `_flushHoldIfReady`: the rows re-render in layout coordinates and the // element moves by the same amount in one paint. private _holdOffset = 0 + // When the last wheel event came (`now()`), listened for on WebKit only. + private _lastWheelAt: number | null = null + // The frame a prepend's anchor write waits for (`_holdAnchorUnderWheel`). + private _anchorHoldFrame: number | null = null // Whether the element's last scroll event reported a position past either // edge (the rubber-band bounce). Judged at report time against the // element's own max, with a 1px tolerance for a fractional scrollTop: a @@ -1087,6 +1096,11 @@ export class Virtualizer< // just removed), deferring every adjustment on the new element until // its next touch cycle. this._holdOffset = 0 + if (this._anchorHoldFrame !== null && this.targetWindow) { + this.targetWindow.cancelAnimationFrame(this._anchorHoldFrame) + } + this._anchorHoldFrame = null + this._lastWheelAt = null this._reportedOverscroll = false this._trailing = 0 // (The gesture was ended with its listeners, in the unsubs above.) @@ -1286,9 +1300,15 @@ export class Virtualizer< // Touch event listeners (iOS-aware deferral). if ('addEventListener' in this.scrollElement) { - this.unsubs.push( - this._iosGesture.listen(this.scrollElement as unknown as EventTarget), - ) + const target = this.scrollElement as unknown as EventTarget + this.unsubs.push(this._iosGesture.listen(target)) + if (isWebKit()) { + const onWheel = () => { + this._lastWheelAt = this.now() + } + target.addEventListener('wheel', onWheel, addEventListenerOptions) + this.unsubs.push(() => target.removeEventListener('wheel', onWheel)) + } } this._scrollToOffset(this.getScrollOffset()) @@ -1314,6 +1334,7 @@ export class Virtualizer< // it and this commit (a concurrent render) can have changed that. // Hold the delta after all and have the rows re-rendered shifted; // an update scheduled from a layout effect commits before paint. + this._holdAnchorUnderWheel() if (!this._canWriteScroll()) { this._holdOffset += anchor.delta this._followAnchor(anchor.delta) @@ -1443,11 +1464,43 @@ export class Virtualizer< // #1307), so a correction is held through the tail on every version; // - not while the element is overscrolled past either edge (the // rubber-band bounce): WebKit discards the write and the bounce can - // stall where it was (#1287). + // stall where it was (#1287); + // - not while a prepend made under wheel input waits for its frames + // (`_holdAnchorUnderWheel`). // A write that is unwanted for another reason (a travelling smooth scroll // owns the position) is a separate check at the call sites. private _canWriteScroll = () => - !(isIOSWebKit() && this._iosGesture.inMotion()) && !this._reportedOverscroll + !(isIOSWebKit() && this._iosGesture.inMotion()) && + !this._reportedOverscroll && + this._anchorHoldFrame === null + + // WebKit can drop a scrollTop write made while wheel input drives the + // scroll: the scrolling thread carries on from where it was. A prepend's + // anchor write lost that way throws the reader by the whole prepend + // (#1398). Held for two frames and written from the second, it stays: + // 0 jumps in 42 runs of the issue's repro in Playwright WebKit 26.0, + // where the write from `_willUpdate` jumped in about 1 run of 4 and a + // write from the next scroll event in 4 of 7. Real Safari and trackpad + // momentum are not measured. Size corrections are written as before; + // one arriving within the two frames joins the hold. + private _holdAnchorUnderWheel = () => { + const win = this.targetWindow + if ( + win === null || + this._anchorHoldFrame !== null || + this._lastWheelAt === null || + this.now() - this._lastWheelAt >= 150 + ) { + return + } + this._anchorHoldFrame = win.requestAnimationFrame(() => { + this._anchorHoldFrame = win.requestAnimationFrame(() => { + this._anchorHoldFrame = null + this._flushHoldIfReady(true) + this._retryClampedAdjustment() + }) + }) + } // Write a held correction once a write is possible, from the scroll // handler, the touch tail timer, `_willUpdate` and a resize notify. The diff --git a/packages/virtual-core/src/ios-gesture.ts b/packages/virtual-core/src/ios-gesture.ts index cda397d4a..d0ac84867 100644 --- a/packages/virtual-core/src/ios-gesture.ts +++ b/packages/virtual-core/src/ios-gesture.ts @@ -43,9 +43,21 @@ export const iosMomentumOverridesWrites = (): boolean => { export const momentumOverridesWrites = (): boolean => !isIOSWebKit() || iosMomentumOverridesWrites() +// Any WebKit: Safari, a WKWebView app, every browser on iOS. Chromium's +// user agent names AppleWebKit too. Cached like the iOS check; SSR-safe. +let _isWebKitResult: boolean | undefined +export const isWebKit = (): boolean => { + if (_isWebKitResult !== undefined) return _isWebKitResult + if (typeof navigator === 'undefined') return (_isWebKitResult = false) + const ua = navigator.userAgent + return (_isWebKitResult = + /AppleWebKit/.test(ua) && !/Chrome|Chromium|Android/.test(ua)) +} + // Test hook: reset the iOS detection caches. Not exported. export const _resetIOSDetectionForTests = () => { _isIOSResult = undefined + _isWebKitResult = undefined _iosMomentumOverridesWritesResult = undefined } diff --git a/packages/virtual-core/tests/wheel-anchor.test.ts b/packages/virtual-core/tests/wheel-anchor.test.ts new file mode 100644 index 000000000..cfaff2af1 --- /dev/null +++ b/packages/virtual-core/tests/wheel-anchor.test.ts @@ -0,0 +1,121 @@ +import { expect, test } from 'vitest' +import { _resetIOSDetectionForTests } from '../src/index' +import { makeDeferralHarness } from './helpers' + +const SAFARI = + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Safari/605.1.15' +const CHROME = + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36' + +function withUserAgent(userAgent: string, fn: () => void) { + Object.defineProperty(navigator, 'userAgent', { + value: userAgent, + configurable: true, + }) + _resetIOSDetectionForTests() + try { + fn() + } finally { + delete (navigator as any).userAgent + _resetIOSDetectionForTests() + } +} + +// An end-anchored list at rest at 2000, rows 50px. +function endAnchoredAt2000() { + const h = makeDeferralHarness({ ios: false }) + h.v.setOptions({ ...h.v.options, anchorTo: 'end', getItemKey: (i) => i }) + h.v._willUpdate() + h.v.scrollToOffset(2000) + h.scroll(true) + for (let i = 0; i < 5; i++) h.frame() + h.scroll(false) + h.writes.length = 0 + return h +} + +// 12 rows of 50px above the reader: the anchor write is 600px. +function prepend(h: ReturnType) { + h.v.setOptions({ ...h.v.options, count: 112, getItemKey: (i) => i - 12 }) + h.v._willUpdate() +} + +test('WebKit (#1398): a prepend under wheel input is written two frames later', () => { + withUserAgent(SAFARI, () => { + const h = endAnchoredAt2000() + h.el._dispatch('wheel') + h.scroll(true, 1900) + const top = h.rowTop(40) + + prepend(h) + expect(h.writes).toEqual([]) + // The reader's row (now index 52) has not moved. + expect(h.v.getVirtualItems().find((item) => item.index === 52)!.start).toBe( + top + h.el.scrollTop, + ) + + // The wheel carries on meanwhile; a scroll event does not flush. + h.el._dispatch('wheel') + h.scroll(true, 1800) + h.frame() + expect(h.writes).toEqual([]) + + h.frame() + expect(h.writes).toEqual([2400]) + expect(h.rowTop(52)).toBe(top + 100) + }) +}) + +test('WebKit (#1398): a size correction within the two frames joins the hold', () => { + withUserAgent(SAFARI, () => { + const h = endAnchoredAt2000() + h.el._dispatch('wheel') + prepend(h) + h.v.resizeItem(0, 70) + expect(h.writes).toEqual([]) + h.frame() + h.frame() + expect(h.writes).toEqual([2620]) + }) +}) + +test('WebKit: a size correction under wheel input is written at once', () => { + withUserAgent(SAFARI, () => { + const h = endAnchoredAt2000() + h.el._dispatch('wheel') + h.v.resizeItem(0, 70) + expect(h.writes).toEqual([2020]) + }) +}) + +test('WebKit: a prepend 150ms after the last wheel event is written at once', () => { + withUserAgent(SAFARI, () => { + const h = endAnchoredAt2000() + h.el._dispatch('wheel') + h.advance(150) + prepend(h) + expect(h.writes).toEqual([2600]) + }) +}) + +test('WebKit: a new scroll element drops the wait', () => { + withUserAgent(SAFARI, () => { + const h = endAnchoredAt2000() + h.el._dispatch('wheel') + prepend(h) + expect(h.v['_anchorHoldFrame']).not.toBeNull() + h.v.setOptions({ ...h.v.options, enabled: false }) + h.v._willUpdate() + expect(h.v['_anchorHoldFrame']).toBeNull() + expect(h.v['_lastWheelAt']).toBeNull() + }) +}) + +test('not WebKit: a prepend under wheel input is written at once', () => { + withUserAgent(CHROME, () => { + const h = endAnchoredAt2000() + h.el._dispatch('wheel') + prepend(h) + expect(h.writes).toEqual([2600]) + }) +}) From 9572c54b12aee529756fd6f02480ca1e5b119101 Mon Sep 17 00:00:00 2001 From: Damian Pieczynski Date: Fri, 27 Nov 2026 06:36:46 +0100 Subject: [PATCH 2/4] fix(virtual-core): hold every correction under WebKit wheel input A scrollTop write made while wheel input drives the scroll makes WebKit discard the distance of the next wheel event. A list whose rows are measured on the way up writes on most frames, so a wheel event per frame lost about a third of its distance; holding only a prepend's anchor did not help there. Hold every correction while wheel input runs and write it when the wheel has been quiet for 150ms. A hold also has to be written when the element reaches either edge, or wheel input that never pauses parks the reader there: two frames later, and not before the edge, where WebKit applies the write about two frames after the rows moved. Measured with the issue's repro in Playwright WebKit 26.0, one wheel event per frame: 0px lost of 7,000 without prepends (main: about 2,300), about 1,000px of 30,000 with five prepends (main: about 10,000), no frame with the rows out of place. Real Safari and trackpad momentum are not measured. --- .changeset/webkit-wheel-prepend-anchor.md | 2 +- packages/virtual-core/src/index.ts | 108 +++++++---- .../virtual-core/tests/wheel-anchor.test.ts | 121 ------------ .../virtual-core/tests/wheel-hold.test.ts | 179 ++++++++++++++++++ 4 files changed, 251 insertions(+), 159 deletions(-) delete mode 100644 packages/virtual-core/tests/wheel-anchor.test.ts create mode 100644 packages/virtual-core/tests/wheel-hold.test.ts diff --git a/.changeset/webkit-wheel-prepend-anchor.md b/.changeset/webkit-wheel-prepend-anchor.md index 93e983581..7460753e3 100644 --- a/.changeset/webkit-wheel-prepend-anchor.md +++ b/.changeset/webkit-wheel-prepend-anchor.md @@ -2,4 +2,4 @@ '@tanstack/virtual-core': patch --- -Fix an end-anchored list losing the reader's place in WebKit when rows are prepended during wheel or trackpad scrolling. The anchor write is now made two frames later, where WebKit keeps it. +Fix wheel and trackpad scrolling in WebKit losing distance, or the reader's place, when rows are measured or prepended on the way. Scroll corrections are now held while wheel input drives the scroll and written when it rests, or when the element reaches either edge. diff --git a/packages/virtual-core/src/index.ts b/packages/virtual-core/src/index.ts index 7a641695e..f1bd9023d 100644 --- a/packages/virtual-core/src/index.ts +++ b/packages/virtual-core/src/index.ts @@ -545,10 +545,12 @@ export class Virtualizer< // `_flushHoldIfReady`: the rows re-render in layout coordinates and the // element moves by the same amount in one paint. private _holdOffset = 0 - // When the last wheel event came (`now()`), listened for on WebKit only. - private _lastWheelAt: number | null = null - // The frame a prepend's anchor write waits for (`_holdAnchorUnderWheel`). - private _anchorHoldFrame: number | null = null + // Set while wheel input drives the scroll in WebKit: from a wheel event + // until 150ms pass without one. Corrections are held meanwhile (see + // `_canWriteScroll`). + private _wheelTimer: number | null = null + // The frame a hold at an edge is written in (`_flushHoldAtEdge`). + private _edgeFlushFrame: number | null = null // Whether the element's last scroll event reported a position past either // edge (the rubber-band bounce). Judged at report time against the // element's own max, with a 1px tolerance for a fractional scrollTop: a @@ -1096,11 +1098,16 @@ export class Virtualizer< // just removed), deferring every adjustment on the new element until // its next touch cycle. this._holdOffset = 0 - if (this._anchorHoldFrame !== null && this.targetWindow) { - this.targetWindow.cancelAnimationFrame(this._anchorHoldFrame) + if (this.targetWindow) { + if (this._wheelTimer !== null) { + this.targetWindow.clearTimeout(this._wheelTimer) + } + if (this._edgeFlushFrame !== null) { + this.targetWindow.cancelAnimationFrame(this._edgeFlushFrame) + } } - this._anchorHoldFrame = null - this._lastWheelAt = null + this._wheelTimer = null + this._edgeFlushFrame = null this._reportedOverscroll = false this._trailing = 0 // (The gesture was ended with its listeners, in the unsubs above.) @@ -1290,6 +1297,7 @@ export class Virtualizer< // A held correction is written once a write is possible. this._flushHoldIfReady(true) + this._flushHoldAtEdge() if (this.scrollState) { this.scheduleScrollReconcile() @@ -1304,7 +1312,16 @@ export class Virtualizer< this.unsubs.push(this._iosGesture.listen(target)) if (isWebKit()) { const onWheel = () => { - this._lastWheelAt = this.now() + const win = this.targetWindow + if (win === null) return + if (this._wheelTimer !== null) win.clearTimeout(this._wheelTimer) + this._wheelTimer = win.setTimeout(() => { + this._wheelTimer = null + this._flushHoldIfReady(true) + this._retryClampedAdjustment() + }, 150) + // At an edge the element stops moving, so no scroll event comes. + this._flushHoldAtEdge() } target.addEventListener('wheel', onWheel, addEventListenerOptions) this.unsubs.push(() => target.removeEventListener('wheel', onWheel)) @@ -1334,7 +1351,6 @@ export class Virtualizer< // it and this commit (a concurrent render) can have changed that. // Hold the delta after all and have the rows re-rendered shifted; // an update scheduled from a layout effect commits before paint. - this._holdAnchorUnderWheel() if (!this._canWriteScroll()) { this._holdOffset += anchor.delta this._followAnchor(anchor.delta) @@ -1465,39 +1481,54 @@ export class Virtualizer< // - not while the element is overscrolled past either edge (the // rubber-band bounce): WebKit discards the write and the bounce can // stall where it was (#1287); - // - not while a prepend made under wheel input waits for its frames - // (`_holdAnchorUnderWheel`). + // - not in WebKit while wheel input drives the scroll: the write lands, + // but WebKit then discards the distance of the next wheel event, and a + // list of rows measured on the way up writes on most frames. In + // Playwright WebKit 26.0 a wheel event per frame lost about a third of + // its distance that way (#1398, #1400); a prepend's anchor write could + // be undone whole. Real Safari and trackpad momentum are not measured. // A write that is unwanted for another reason (a travelling smooth scroll // owns the position) is a separate check at the call sites. private _canWriteScroll = () => - !(isIOSWebKit() && this._iosGesture.inMotion()) && - !this._reportedOverscroll && - this._anchorHoldFrame === null - - // WebKit can drop a scrollTop write made while wheel input drives the - // scroll: the scrolling thread carries on from where it was. A prepend's - // anchor write lost that way throws the reader by the whole prepend - // (#1398). Held for two frames and written from the second, it stays: - // 0 jumps in 42 runs of the issue's repro in Playwright WebKit 26.0, - // where the write from `_willUpdate` jumped in about 1 run of 4 and a - // write from the next scroll event in 4 of 7. Real Safari and trackpad - // momentum are not measured. Size corrections are written as before; - // one arriving within the two frames joins the hold. - private _holdAnchorUnderWheel = () => { + this._elementTakesWrite() && this._wheelTimer === null + + // The first two of those: the element would ignore or discard the write. + private _elementTakesWrite = () => + !(isIOSWebKit() && this._iosGesture.inMotion()) && !this._reportedOverscroll + + // A hold shifts the rows and leaves the element where it is, so the + // element reaches its edge while the layout has `_holdOffset` further to + // go, or the other way round. Wheel input that never pauses would park + // the reader there. At either edge the hold is written while the wheel + // still runs, two frames later (a prepend's anchor written at once can be + // undone, #1398). Not before the edge: while the element still moves, + // WebKit applies the write about two frames after the rows have gone + // back to layout coordinates, and they show `_holdOffset` away for those + // frames (measured with a 1200px and a one-viewport margin, #1400). At + // the edge the element has nowhere to go and the write lands with the + // rows. Past the edge (a bounce) the write waits: the next wheel or + // scroll event tries again. + private _flushHoldAtEdge = () => { const win = this.targetWindow if ( win === null || - this._anchorHoldFrame !== null || - this._lastWheelAt === null || - this.now() - this._lastWheelAt >= 150 + this._holdOffset === 0 || + this._wheelTimer === null || + this._edgeFlushFrame !== null ) { return } - this._anchorHoldFrame = win.requestAnimationFrame(() => { - this._anchorHoldFrame = win.requestAnimationFrame(() => { - this._anchorHoldFrame = null - this._flushHoldIfReady(true) - this._retryClampedAdjustment() + const offset = this._readElementOffset() + const max = this._elementMaxScrollOffset() + if (offset === null || max === null) return + // 1px for a fractional scrollTop. + if (offset >= 1 && offset + this._holdOffset >= 1 && max - offset >= 1) { + return + } + this._edgeFlushFrame = win.requestAnimationFrame(() => { + this._edgeFlushFrame = win.requestAnimationFrame(() => { + this._edgeFlushFrame = null + this._flushHoldIfReady(true, true) }) }) } @@ -1508,11 +1539,14 @@ export class Virtualizer< // notify issued before the write, so the sizer can take the position and // both commit in the paint the write lands in. `sync` is false only where // the caller already runs inside the consumer's commit (`_willUpdate`), - // where an update it schedules commits before paint anyway. - private _flushHoldIfReady = (sync: boolean) => { + // where an update it schedules commits before paint anyway. `underWheel` + // writes although wheel input still runs (`_flushHoldAtEdge`). + private _flushHoldIfReady = (sync: boolean, underWheel = false) => { if (this._holdOffset === 0) return if (!this.scrollElement || !this.options.enabled) return - if (!this._canWriteScroll()) return + if (!(underWheel ? this._elementTakesWrite() : this._canWriteScroll())) { + return + } // Let a travelling smooth scroll land first (see `_willUpdate`). if (this.scrollState?.phase === 'smooth') return this._holdOffset = 0 diff --git a/packages/virtual-core/tests/wheel-anchor.test.ts b/packages/virtual-core/tests/wheel-anchor.test.ts deleted file mode 100644 index cfaff2af1..000000000 --- a/packages/virtual-core/tests/wheel-anchor.test.ts +++ /dev/null @@ -1,121 +0,0 @@ -import { expect, test } from 'vitest' -import { _resetIOSDetectionForTests } from '../src/index' -import { makeDeferralHarness } from './helpers' - -const SAFARI = - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Safari/605.1.15' -const CHROME = - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36' - -function withUserAgent(userAgent: string, fn: () => void) { - Object.defineProperty(navigator, 'userAgent', { - value: userAgent, - configurable: true, - }) - _resetIOSDetectionForTests() - try { - fn() - } finally { - delete (navigator as any).userAgent - _resetIOSDetectionForTests() - } -} - -// An end-anchored list at rest at 2000, rows 50px. -function endAnchoredAt2000() { - const h = makeDeferralHarness({ ios: false }) - h.v.setOptions({ ...h.v.options, anchorTo: 'end', getItemKey: (i) => i }) - h.v._willUpdate() - h.v.scrollToOffset(2000) - h.scroll(true) - for (let i = 0; i < 5; i++) h.frame() - h.scroll(false) - h.writes.length = 0 - return h -} - -// 12 rows of 50px above the reader: the anchor write is 600px. -function prepend(h: ReturnType) { - h.v.setOptions({ ...h.v.options, count: 112, getItemKey: (i) => i - 12 }) - h.v._willUpdate() -} - -test('WebKit (#1398): a prepend under wheel input is written two frames later', () => { - withUserAgent(SAFARI, () => { - const h = endAnchoredAt2000() - h.el._dispatch('wheel') - h.scroll(true, 1900) - const top = h.rowTop(40) - - prepend(h) - expect(h.writes).toEqual([]) - // The reader's row (now index 52) has not moved. - expect(h.v.getVirtualItems().find((item) => item.index === 52)!.start).toBe( - top + h.el.scrollTop, - ) - - // The wheel carries on meanwhile; a scroll event does not flush. - h.el._dispatch('wheel') - h.scroll(true, 1800) - h.frame() - expect(h.writes).toEqual([]) - - h.frame() - expect(h.writes).toEqual([2400]) - expect(h.rowTop(52)).toBe(top + 100) - }) -}) - -test('WebKit (#1398): a size correction within the two frames joins the hold', () => { - withUserAgent(SAFARI, () => { - const h = endAnchoredAt2000() - h.el._dispatch('wheel') - prepend(h) - h.v.resizeItem(0, 70) - expect(h.writes).toEqual([]) - h.frame() - h.frame() - expect(h.writes).toEqual([2620]) - }) -}) - -test('WebKit: a size correction under wheel input is written at once', () => { - withUserAgent(SAFARI, () => { - const h = endAnchoredAt2000() - h.el._dispatch('wheel') - h.v.resizeItem(0, 70) - expect(h.writes).toEqual([2020]) - }) -}) - -test('WebKit: a prepend 150ms after the last wheel event is written at once', () => { - withUserAgent(SAFARI, () => { - const h = endAnchoredAt2000() - h.el._dispatch('wheel') - h.advance(150) - prepend(h) - expect(h.writes).toEqual([2600]) - }) -}) - -test('WebKit: a new scroll element drops the wait', () => { - withUserAgent(SAFARI, () => { - const h = endAnchoredAt2000() - h.el._dispatch('wheel') - prepend(h) - expect(h.v['_anchorHoldFrame']).not.toBeNull() - h.v.setOptions({ ...h.v.options, enabled: false }) - h.v._willUpdate() - expect(h.v['_anchorHoldFrame']).toBeNull() - expect(h.v['_lastWheelAt']).toBeNull() - }) -}) - -test('not WebKit: a prepend under wheel input is written at once', () => { - withUserAgent(CHROME, () => { - const h = endAnchoredAt2000() - h.el._dispatch('wheel') - prepend(h) - expect(h.writes).toEqual([2600]) - }) -}) diff --git a/packages/virtual-core/tests/wheel-hold.test.ts b/packages/virtual-core/tests/wheel-hold.test.ts new file mode 100644 index 000000000..356f10e4c --- /dev/null +++ b/packages/virtual-core/tests/wheel-hold.test.ts @@ -0,0 +1,179 @@ +import { expect, test } from 'vitest' +import { _resetIOSDetectionForTests } from '../src/index' +import { makeDeferralHarness } from './helpers' + +const SAFARI = + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Safari/605.1.15' +const CHROME = + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36' + +function withUserAgent(userAgent: string, fn: () => void) { + Object.defineProperty(navigator, 'userAgent', { + value: userAgent, + configurable: true, + }) + _resetIOSDetectionForTests() + try { + fn() + } finally { + delete (navigator as any).userAgent + _resetIOSDetectionForTests() + } +} + +// An end-anchored list at rest at 2000: rows 50px, viewport 200px, the +// element's max 4800. `expireTail` runs the wheel timer: 150ms with no +// wheel event. +function endAnchoredAt2000() { + const h = makeDeferralHarness({ ios: false }) + h.v.setOptions({ ...h.v.options, anchorTo: 'end', getItemKey: (i) => i }) + h.v._willUpdate() + h.v.scrollToOffset(2000) + h.scroll(true) + for (let i = 0; i < 5; i++) h.frame() + h.scroll(false) + h.writes.length = 0 + return h +} + +// 12 rows of 50px above the reader: the anchor write is 600px. +function prepend(h: ReturnType) { + h.v.setOptions({ ...h.v.options, count: 112, getItemKey: (i) => i - 12 }) + h.v._willUpdate() +} + +test('WebKit (#1398): a size correction under wheel input is held until the wheel rests', () => { + withUserAgent(SAFARI, () => { + const h = endAnchoredAt2000() + h.el._dispatch('wheel') + h.scroll(true, 1900) + const top = h.rowTop(40) + + h.v.resizeItem(0, 70) + expect(h.writes).toEqual([]) + // Row 40 is exposed where the reader sees it. + expect(h.v.getVirtualItems().find((item) => item.index === 40)!.start).toBe( + top + h.el.scrollTop, + ) + + // The wheel carries on: neither a scroll event nor a frame writes. + h.el._dispatch('wheel') + h.scroll(true, 1800) + h.frame() + h.frame() + expect(h.writes).toEqual([]) + + h.expireTail() + expect(h.writes).toEqual([1820]) + expect(h.rowTop(40)).toBe(top + 100) + }) +}) + +test('WebKit (#1398): a prepend under wheel input is held until the wheel rests', () => { + withUserAgent(SAFARI, () => { + const h = endAnchoredAt2000() + h.el._dispatch('wheel') + h.scroll(true, 1900) + const top = h.rowTop(40) + + prepend(h) + expect(h.writes).toEqual([]) + expect(h.v.getVirtualItems().find((item) => item.index === 52)!.start).toBe( + top + h.el.scrollTop, + ) + + h.expireTail() + expect(h.writes).toEqual([2500]) + expect(h.rowTop(52)).toBe(top) + }) +}) + +test('WebKit: a hold is written two frames after the element reaches the top, the wheel still running', () => { + withUserAgent(SAFARI, () => { + const h = endAnchoredAt2000() + h.el._dispatch('wheel') + prepend(h) + // Not before the edge. + h.scroll(true, 100) + h.frame() + h.frame() + expect(h.writes).toEqual([]) + + h.el._dispatch('wheel') + h.scroll(true, 0) + h.frame() + expect(h.writes).toEqual([]) + h.frame() + expect(h.writes).toEqual([600]) + + // The wheel still holds what comes next. + h.writes.length = 0 + h.scroll(true, 600) + h.v.resizeItem(0, 70) + expect(h.writes).toEqual([]) + }) +}) + +test('WebKit: a hold at the top is written with no scroll event, from the wheel event', () => { + withUserAgent(SAFARI, () => { + const h = endAnchoredAt2000() + h.el._dispatch('wheel') + h.scroll(true, 0) + prepend(h) + expect(h.writes).toEqual([]) + h.el._dispatch('wheel') + h.frame() + h.frame() + expect(h.writes).toEqual([600]) + }) +}) + +test('WebKit: a hold is written two frames after the element reaches the end', () => { + withUserAgent(SAFARI, () => { + const h = endAnchoredAt2000() + h.el._dispatch('wheel') + h.scroll(true, 4800) + h.v.resizeItem(0, 70) + expect(h.writes).toEqual([]) + h.el._dispatch('wheel') + h.frame() + h.frame() + expect(h.writes).toEqual([4820]) + }) +}) + +test('WebKit: a correction with no wheel input is written at once', () => { + withUserAgent(SAFARI, () => { + const h = endAnchoredAt2000() + h.v.resizeItem(0, 70) + expect(h.writes).toEqual([2020]) + }) +}) + +test('WebKit: a new scroll element drops the wheel state', () => { + withUserAgent(SAFARI, () => { + const h = endAnchoredAt2000() + h.el._dispatch('wheel') + h.scroll(true, 0) + prepend(h) + h.el._dispatch('wheel') + expect(h.v['_wheelTimer']).not.toBeNull() + expect(h.v['_edgeFlushFrame']).not.toBeNull() + h.v.setOptions({ ...h.v.options, enabled: false }) + h.v._willUpdate() + expect(h.v['_wheelTimer']).toBeNull() + expect(h.v['_edgeFlushFrame']).toBeNull() + }) +}) + +test('not WebKit: corrections under wheel input are written at once', () => { + withUserAgent(CHROME, () => { + const h = endAnchoredAt2000() + h.el._dispatch('wheel') + h.v.resizeItem(0, 70) + expect(h.writes).toEqual([2020]) + h.writes.length = 0 + prepend(h) + expect(h.writes).toEqual([2620]) + }) +}) From 462bdacc1f9b68b3ee7e52ac05955a2d851f836c Mon Sep 17 00:00:00 2001 From: Damian Pieczynski Date: Fri, 27 Nov 2026 06:51:37 +0100 Subject: [PATCH 3/4] fix(virtual-core): write a wheel hold at the top of the list only Review follow-ups on the WebKit wheel hold: - The end needs no early write: the total size is exposed short by the hold, so the element and the layout reach the end together. - The write at the top ends the wheel hold early instead of passing a flag through the flush; the next wheel event starts it again. - Check the top again when the two frames have passed: the reader can have turned back, and a write away from the top shows the rows out of place. - The list's top is scrollMargin down the element; held rows were drawn over what is above the list. - jsdom and happy-dom name AppleWebKit in their user agent: leave them out, so a consumer's test sees the same writes as before. --- .changeset/webkit-wheel-prepend-anchor.md | 2 +- packages/virtual-core/src/index.ts | 98 ++++++++++--------- packages/virtual-core/src/ios-gesture.ts | 7 +- .../virtual-core/tests/wheel-hold.test.ts | 58 ++++++++++- 4 files changed, 111 insertions(+), 54 deletions(-) diff --git a/.changeset/webkit-wheel-prepend-anchor.md b/.changeset/webkit-wheel-prepend-anchor.md index 7460753e3..f016df448 100644 --- a/.changeset/webkit-wheel-prepend-anchor.md +++ b/.changeset/webkit-wheel-prepend-anchor.md @@ -2,4 +2,4 @@ '@tanstack/virtual-core': patch --- -Fix wheel and trackpad scrolling in WebKit losing distance, or the reader's place, when rows are measured or prepended on the way. Scroll corrections are now held while wheel input drives the scroll and written when it rests, or when the element reaches either edge. +Fix wheel scrolling in WebKit losing distance, or the reader's place, when rows are measured or prepended on the way. Scroll corrections are now held for 150ms after a wheel event and written when the wheel rests, or when the element reaches the top of the list. diff --git a/packages/virtual-core/src/index.ts b/packages/virtual-core/src/index.ts index f1bd9023d..3401a951a 100644 --- a/packages/virtual-core/src/index.ts +++ b/packages/virtual-core/src/index.ts @@ -545,11 +545,11 @@ export class Virtualizer< // `_flushHoldIfReady`: the rows re-render in layout coordinates and the // element moves by the same amount in one paint. private _holdOffset = 0 - // Set while wheel input drives the scroll in WebKit: from a wheel event - // until 150ms pass without one. Corrections are held meanwhile (see - // `_canWriteScroll`). + // Set in WebKit from a wheel event until 150ms pass without one, whether + // or not that event scrolled this element. Corrections are held meanwhile + // (see `_canWriteScroll`). private _wheelTimer: number | null = null - // The frame a hold at an edge is written in (`_flushHoldAtEdge`). + // The frame a hold at the top is written in (`_flushHoldAtTop`). private _edgeFlushFrame: number | null = null // Whether the element's last scroll event reported a position past either // edge (the rubber-band bounce). Judged at report time against the @@ -1297,7 +1297,7 @@ export class Virtualizer< // A held correction is written once a write is possible. this._flushHoldIfReady(true) - this._flushHoldAtEdge() + this._flushHoldAtTop() if (this.scrollState) { this.scheduleScrollReconcile() @@ -1320,8 +1320,8 @@ export class Virtualizer< this._flushHoldIfReady(true) this._retryClampedAdjustment() }, 150) - // At an edge the element stops moving, so no scroll event comes. - this._flushHoldAtEdge() + // At the top the element stops moving, so no scroll event comes. + this._flushHoldAtTop() } target.addEventListener('wheel', onWheel, addEventListenerOptions) this.unsubs.push(() => target.removeEventListener('wheel', onWheel)) @@ -1481,54 +1481,63 @@ export class Virtualizer< // - not while the element is overscrolled past either edge (the // rubber-band bounce): WebKit discards the write and the bounce can // stall where it was (#1287); - // - not in WebKit while wheel input drives the scroll: the write lands, - // but WebKit then discards the distance of the next wheel event, and a - // list of rows measured on the way up writes on most frames. In - // Playwright WebKit 26.0 a wheel event per frame lost about a third of - // its distance that way (#1398, #1400); a prepend's anchor write could - // be undone whole. Real Safari and trackpad momentum are not measured. + // - not in WebKit within 150ms of a wheel event: the write lands, but + // WebKit then discards the distance of the next wheel event, and a list + // of rows measured on the way up writes on most frames. In Playwright + // WebKit 26.0 a wheel event per frame lost about a third of its + // distance that way (#1398, #1400); a prepend's anchor write could be + // undone whole. Real Safari and trackpad momentum are not measured. // A write that is unwanted for another reason (a travelling smooth scroll // owns the position) is a separate check at the call sites. private _canWriteScroll = () => - this._elementTakesWrite() && this._wheelTimer === null - - // The first two of those: the element would ignore or discard the write. - private _elementTakesWrite = () => - !(isIOSWebKit() && this._iosGesture.inMotion()) && !this._reportedOverscroll + !(isIOSWebKit() && this._iosGesture.inMotion()) && + !this._reportedOverscroll && + this._wheelTimer === null // A hold shifts the rows and leaves the element where it is, so the - // element reaches its edge while the layout has `_holdOffset` further to - // go, or the other way round. Wheel input that never pauses would park - // the reader there. At either edge the hold is written while the wheel - // still runs, two frames later (a prepend's anchor written at once can be - // undone, #1398). Not before the edge: while the element still moves, - // WebKit applies the write about two frames after the rows have gone - // back to layout coordinates, and they show `_holdOffset` away for those - // frames (measured with a 1200px and a one-viewport margin, #1400). At - // the edge the element has nowhere to go and the write lands with the - // rows. Past the edge (a bounce) the write waits: the next wheel or - // scroll event tries again. - private _flushHoldAtEdge = () => { + // element reaches its top while the layout has `_holdOffset` further to + // go (or, for a negative hold, the layout reaches its top first). Wheel + // input that never pauses would park the reader there, so there the wheel + // hold ends early and the hold is written, two frames later (a prepend's + // anchor written at once can be undone, #1398). The next wheel event + // starts the wheel hold again. Not before the top: while the element + // still moves, WebKit applies the write about two frames after the rows + // have gone back to layout coordinates, and they show `_holdOffset` away + // for those frames (measured with a 1200px and a one-viewport margin, + // #1400). The list's top is `scrollMargin` down the element, where held + // rows would be drawn over what is above the list; the element still + // moves there, so those frames are the lesser evil. Past the top (a + // bounce) the write waits: the next wheel or scroll event tries again. + // The end needs none of this: the total size is exposed short by the + // hold, so the element and the layout reach it together. + private _holdAtTop = () => { + if (this._holdOffset === 0) return false + const offset = this._readElementOffset() + // 1px for a fractional scrollTop. + return ( + offset !== null && + (offset < this.options.scrollMargin + 1 || offset + this._holdOffset < 1) + ) + } + private _flushHoldAtTop = () => { const win = this.targetWindow if ( win === null || - this._holdOffset === 0 || this._wheelTimer === null || - this._edgeFlushFrame !== null + this._edgeFlushFrame !== null || + !this._holdAtTop() ) { return } - const offset = this._readElementOffset() - const max = this._elementMaxScrollOffset() - if (offset === null || max === null) return - // 1px for a fractional scrollTop. - if (offset >= 1 && offset + this._holdOffset >= 1 && max - offset >= 1) { - return - } this._edgeFlushFrame = win.requestAnimationFrame(() => { this._edgeFlushFrame = win.requestAnimationFrame(() => { this._edgeFlushFrame = null - this._flushHoldIfReady(true, true) + // The reader can have turned back within the two frames. + if (this._wheelTimer === null || !this._holdAtTop()) return + win.clearTimeout(this._wheelTimer) + this._wheelTimer = null + this._flushHoldIfReady(true) + this._retryClampedAdjustment() }) }) } @@ -1539,14 +1548,11 @@ export class Virtualizer< // notify issued before the write, so the sizer can take the position and // both commit in the paint the write lands in. `sync` is false only where // the caller already runs inside the consumer's commit (`_willUpdate`), - // where an update it schedules commits before paint anyway. `underWheel` - // writes although wheel input still runs (`_flushHoldAtEdge`). - private _flushHoldIfReady = (sync: boolean, underWheel = false) => { + // where an update it schedules commits before paint anyway. + private _flushHoldIfReady = (sync: boolean) => { if (this._holdOffset === 0) return if (!this.scrollElement || !this.options.enabled) return - if (!(underWheel ? this._elementTakesWrite() : this._canWriteScroll())) { - return - } + if (!this._canWriteScroll()) return // Let a travelling smooth scroll land first (see `_willUpdate`). if (this.scrollState?.phase === 'smooth') return this._holdOffset = 0 diff --git a/packages/virtual-core/src/ios-gesture.ts b/packages/virtual-core/src/ios-gesture.ts index d0ac84867..d803ba982 100644 --- a/packages/virtual-core/src/ios-gesture.ts +++ b/packages/virtual-core/src/ios-gesture.ts @@ -44,14 +44,17 @@ export const momentumOverridesWrites = (): boolean => !isIOSWebKit() || iosMomentumOverridesWrites() // Any WebKit: Safari, a WKWebView app, every browser on iOS. Chromium's -// user agent names AppleWebKit too. Cached like the iOS check; SSR-safe. +// user agent names AppleWebKit too, and so do jsdom's and happy-dom's, where +// a consumer's test must see the same writes as before. Cached like the iOS +// check; SSR-safe. let _isWebKitResult: boolean | undefined export const isWebKit = (): boolean => { if (_isWebKitResult !== undefined) return _isWebKitResult if (typeof navigator === 'undefined') return (_isWebKitResult = false) const ua = navigator.userAgent return (_isWebKitResult = - /AppleWebKit/.test(ua) && !/Chrome|Chromium|Android/.test(ua)) + /AppleWebKit/.test(ua) && + !/Chrome|Chromium|Android|jsdom|HappyDOM/.test(ua)) } // Test hook: reset the iOS detection caches. Not exported. diff --git a/packages/virtual-core/tests/wheel-hold.test.ts b/packages/virtual-core/tests/wheel-hold.test.ts index 356f10e4c..f0a490cda 100644 --- a/packages/virtual-core/tests/wheel-hold.test.ts +++ b/packages/virtual-core/tests/wheel-hold.test.ts @@ -106,9 +106,10 @@ test('WebKit: a hold is written two frames after the element reaches the top, th h.frame() expect(h.writes).toEqual([600]) - // The wheel still holds what comes next. + // The next wheel event holds what comes after it. h.writes.length = 0 h.scroll(true, 600) + h.el._dispatch('wheel') h.v.resizeItem(0, 70) expect(h.writes).toEqual([]) }) @@ -128,17 +129,54 @@ test('WebKit: a hold at the top is written with no scroll event, from the wheel }) }) -test('WebKit: a hold is written two frames after the element reaches the end', () => { +test('WebKit: a hold is not written when the reader leaves the top within the two frames', () => { withUserAgent(SAFARI, () => { const h = endAnchoredAt2000() h.el._dispatch('wheel') - h.scroll(true, 4800) - h.v.resizeItem(0, 70) + prepend(h) + h.scroll(true, 0) + h.frame() + h.el._dispatch('wheel') + h.scroll(true, 400) + h.frame() expect(h.writes).toEqual([]) + + h.expireTail() + expect(h.writes).toEqual([1000]) + }) +}) + +test('WebKit: with a scroll margin a hold is written where the list starts', () => { + withUserAgent(SAFARI, () => { + const h = endAnchoredAt2000() + h.v.setOptions({ ...h.v.options, scrollMargin: 300 }) + h.v._willUpdate() + h.writes.length = 0 h.el._dispatch('wheel') + prepend(h) + h.scroll(true, 400) h.frame() h.frame() - expect(h.writes).toEqual([4820]) + expect(h.writes).toEqual([]) + + // The top of the list: above it held rows would cover the margin. + h.scroll(true, 300) + h.frame() + h.frame() + expect(h.writes).toEqual([900]) + }) +}) + +test('WebKit: a negative hold is written when the layout reaches the top', () => { + withUserAgent(SAFARI, () => { + const h = endAnchoredAt2000() + h.el._dispatch('wheel') + h.v.resizeItem(0, 20) + expect(h.writes).toEqual([]) + h.scroll(true, 30) + h.frame() + h.frame() + expect(h.writes).toEqual([0]) }) }) @@ -177,3 +215,13 @@ test('not WebKit: corrections under wheel input are written at once', () => { expect(h.writes).toEqual([2620]) }) }) + +test('jsdom is not WebKit: corrections under wheel input are written at once', () => { + // jsdom's own user agent names AppleWebKit. + expect(navigator.userAgent).toMatch(/AppleWebKit.*jsdom/) + _resetIOSDetectionForTests() + const h = endAnchoredAt2000() + h.el._dispatch('wheel') + h.v.resizeItem(0, 70) + expect(h.writes).toEqual([2020]) +}) From 20a4038cbe34619a9c3ca55b2ebd4b902f206404 Mon Sep 17 00:00:00 2001 From: Damian Pieczynski Date: Sun, 29 Nov 2026 11:33:18 +0100 Subject: [PATCH 4/4] fix(virtual-core): end the wheel hold when a scroll command starts Review follow-ups on the WebKit wheel hold: - A command is written _holdOffset short of its target. Under a hold larger than the target the element clamps at 0, the command never sees its target, and the flush after it writes the old position: a scrollToIndex(0) right after a prepend under wheel input ended on the old first row, and a smooth one kept the hold back for 5s. End the wheel hold and write the hold before the command. - A negative hold with a scrollMargin was written scrollMargin late: compare the layout position with the list's top too. --- packages/virtual-core/src/index.ts | 17 ++++++- .../virtual-core/tests/wheel-hold.test.ts | 49 +++++++++++++++++++ 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/packages/virtual-core/src/index.ts b/packages/virtual-core/src/index.ts index 3401a951a..76a308fae 100644 --- a/packages/virtual-core/src/index.ts +++ b/packages/virtual-core/src/index.ts @@ -1496,7 +1496,7 @@ export class Virtualizer< // A hold shifts the rows and leaves the element where it is, so the // element reaches its top while the layout has `_holdOffset` further to - // go (or, for a negative hold, the layout reaches its top first). Wheel + // go (or, for a negative hold, the layout reaches the top first). Wheel // input that never pauses would park the reader there, so there the wheel // hold ends early and the hold is written, two frames later (a prepend's // anchor written at once can be undone, #1398). The next wheel event @@ -1516,7 +1516,8 @@ export class Virtualizer< // 1px for a fractional scrollTop. return ( offset !== null && - (offset < this.options.scrollMargin + 1 || offset + this._holdOffset < 1) + Math.min(offset, offset + this._holdOffset) < + this.options.scrollMargin + 1 ) } private _flushHoldAtTop = () => { @@ -2685,6 +2686,18 @@ export class Virtualizer< behavior: ScrollBehavior, kind: 'absolute' | 'relative', ) { + // The command takes over from the wheel: end the wheel hold and write + // what it held first. The command is written `_holdOffset` short of its + // target, so under a hold larger than the target the element clamps at + // 0, the command never sees its target and the flush after it writes + // the old position. The command this one replaces must not keep the + // hold back (`_flushHoldIfReady` waits for a smooth one). + if (this._wheelTimer !== null && this.targetWindow) { + this.targetWindow.clearTimeout(this._wheelTimer) + this._wheelTimer = null + this.scrollState = null + this._flushHoldIfReady(true) + } // A new explicit command supersedes layout-driven work queued before it. // Clear both before any iOS deferral so a later commit/retry cannot // overwrite the user's newer scroll intent. diff --git a/packages/virtual-core/tests/wheel-hold.test.ts b/packages/virtual-core/tests/wheel-hold.test.ts index f0a490cda..eadc41ac6 100644 --- a/packages/virtual-core/tests/wheel-hold.test.ts +++ b/packages/virtual-core/tests/wheel-hold.test.ts @@ -180,6 +180,55 @@ test('WebKit: a negative hold is written when the layout reaches the top', () => }) }) +test('WebKit: with a scroll margin a negative hold is written when the layout reaches the list', () => { + withUserAgent(SAFARI, () => { + const h = endAnchoredAt2000() + h.v.setOptions({ ...h.v.options, scrollMargin: 300 }) + h.v._willUpdate() + h.writes.length = 0 + h.el._dispatch('wheel') + h.v.resizeItem(0, 20) + expect(h.writes).toEqual([]) + // The layout is at 300, where the list starts. + h.scroll(true, 330) + h.frame() + h.frame() + expect(h.writes).toEqual([300]) + }) +}) + +for (const behavior of ['auto', 'smooth'] as const) { + test(`WebKit: scrollToIndex (${behavior}) under a wheel hold reaches a target above the hold`, () => { + withUserAgent(SAFARI, () => { + const h = endAnchoredAt2000() + h.v.setOptions({ + ...h.v.options, + scrollToFn: (offset, { adjustments = 0 }) => { + h.writes.push(offset + adjustments) + // The element clamps a write to its range. + h.el.scrollTop = Math.max(0, Math.min(offset + adjustments, 4800)) + }, + }) + h.el._dispatch('wheel') + h.scroll(true, 500) + prepend(h) + expect(h.v['_holdOffset']).toBe(600) + + // Row 0 is 600px above what the element can reach while it is held. + h.v.scrollToIndex(0, { align: 'start', behavior }) + h.scroll(true) + for (let i = 0; i < 10; i++) h.frame() + h.scroll(false) + for (let i = 0; i < 10; i++) h.frame() + + expect(h.v['_holdOffset']).toBe(0) + expect(h.el.scrollTop).toBe(0) + expect(h.rowTop(0)).toBe(0) + expect(h.v.scrollState).toBeNull() + }) + }) +} + test('WebKit: a correction with no wheel input is written at once', () => { withUserAgent(SAFARI, () => { const h = endAnchoredAt2000()