feat: Generic scroll observation and improved virtualization support#9115
Open
nwidynski wants to merge 8 commits intoadobe:mainfrom
Open
feat: Generic scroll observation and improved virtualization support#9115nwidynski wants to merge 8 commits intoadobe:mainfrom
nwidynski wants to merge 8 commits intoadobe:mainfrom
Conversation
nwidynski
commented
Oct 30, 2025
Contributor
Author
nwidynski
left a comment
There was a problem hiding this comment.
This should be in a working state and good for a round of review!
|
|
||
| constructor(width = 0, height = 0) { | ||
| this.width = Math.min(Math.max(width, 0), Number.MAX_SAFE_INTEGER) || 0; | ||
| this.height = Math.min(Math.max(height, 0), Number.MAX_SAFE_INTEGER) || 0; |
Contributor
Author
There was a problem hiding this comment.
I added an upper bound here, maybe we should do this also for Point and Size?
| * @param rect - The rectangle to check. | ||
| */ | ||
| intersects(rect: IRect): boolean { | ||
| return (this.area > 0 && (rect.width * rect.height) > 0) |
Contributor
Author
There was a problem hiding this comment.
@LFDanLu Removing the Rect intersection bypass, as scrollWidth is now always set by the stub in useScrollViewRef. This also fixes the regression I mentioned.
| rect = this._overscanManager.getOverscannedRect(); | ||
| } | ||
| let layoutInfos = this.layout.getVisibleLayoutInfos(rect); | ||
| let layoutInfos = rect.area === 0 ? [] : this.layout.getVisibleLayoutInfos(rect); |
Contributor
Author
There was a problem hiding this comment.
This isn't required, but we regressed on this previously, so I think its safer to keep just in case.
…spectrum into feat-scrollview
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change aims to break up
useScrollViewinto two generic hooks, designed to be reusable outside of virtualization:useScrollObserver()- built for generic observation of a scrollport inside a scroll containeruseScrollView()- a tiny wrapper on observation, for containers of controlled and uncontrolled content sizesAlong with these hooks, this PR migrates layout utilities, such as
Rect/Point/Size, to@react-stately/utilsand@react-aria/utilswhile also expanding upongetRTLOffsetTypewith support forflex-direction: reversecontainers.Lastly, along with minor bug-fixes, this PR refactors the
VIRT_ONflag to be contained to a single place, while providing more realistic measurements in test environments. This should improve the risk of this flag impacting user code.✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project: