fix(virtual-core): keep an end-pinned viewport pinned when the scroll element shrinks #1298
Openlangleyd(GitHub profile, opens in a new tab)wants to merge 2 commits into
main fromrefs/pull/1298/headopened - packages/virtual-core/src/index.ts line 907OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -890,4 +890,18 @@890890891891 this.unsubs.push(892892 this.options.observeElementRect(this, (rect) => {893+ // With anchorTo: 'end', keep an end-pinned viewport pinned when the894+ // scroll element shrinks, as resizeItem does when an item grows. The895+ // browser keeps scrollTop, so the end would otherwise drop below the896+ // fold. Judge "pinned" against the size before this change, and897+ // never scroll past the element's real end.898+ const prevSize = this.scrollRect !== null ? this.getSize() : null899+ const wasAtEnd =900+ prevSize !== null &&901+ this.options.anchorTo === 'end' &&902+ this.scrollState?.behavior !== 'smooth' &&903+ this.getVirtualDistanceFromEnd() <= this.options.scrollEndThreshold893904 this.scrollRect = rect905+ if (wasAtEnd && prevSize > this.getSize()) {906+ this.applyScrollAdjustment(907+ Math.min(prevSize - this.getSize(), this.getDistanceFromEnd()),
piecyk requested changes
@@ -890,3 +890,9 @@890890891891 this.unsubs.push(892892 this.options.observeElementRect(this, (rect) => {893+ // With anchorTo: 'end', keep an end-pinned viewport pinned when the894+ // scroll element shrinks, as resizeItem does when an item grows. The895+ // browser keeps scrollTop, so the end would otherwise drop below the896+ // fold. Judge "pinned" against the size before this change, and897+ // never scroll past the element's real end.898+ const prevSize = this.scrollRect !== null ? this.getSize() : null@@ -890,3 +890,14 @@890890891891 this.unsubs.push(892892 this.options.observeElementRect(this, (rect) => {893+ // With anchorTo: 'end', keep an end-pinned viewport pinned when the894+ // scroll element shrinks, as resizeItem does when an item grows. The895+ // browser keeps scrollTop, so the end would otherwise drop below the896+ // fold. Judge "pinned" against the size before this change, and897+ // never scroll past the element's real end.898+ const prevSize = this.scrollRect !== null ? this.getSize() : null899+ const wasAtEnd =900+ prevSize !== null &&901+ this.options.anchorTo === 'end' &&902+ this.scrollState?.behavior !== 'smooth' &&903+ this.getVirtualDistanceFromEnd() <= this.options.scrollEndThresholdlangleyd(GitHub profile, opens in a new tab) linked this to fix #1297
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: df83a48b6a01c0789b93ebcec244376a92ee9711
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR