- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.3k
feat: Generic scroll observation and improved virtualization support #9115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't required, but we regressed on this previously, so I think its safer to keep just in case.
…spectrum into feat-scrollview
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: