-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Fabric] Implement snapToAlignment property for ScrollView #14841
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
…ure (#14830) * Initial plan * Implement snapToAlignment support for Fabric ScrollView - interface and prop handling Co-authored-by: anupriya13 <54227869+anupriya13@users.noreply.github.com> * Add test support and UI for snapToAlignment in ScrollView Fabric implementation Co-authored-by: anupriya13 <54227869+anupriya13@users.noreply.github.com> * Remove unnecessary changes from vnext/codegen files Co-authored-by: anupriya13 <54227869+anupriya13@users.noreply.github.com> * Change files * Run yarn change prerelease, yarn lint:fix, and yarn format as requested Co-authored-by: anupriya13 <54227869+anupriya13@users.noreply.github.com> * Remove all changes from vnext/codegen files as requested Co-authored-by: anupriya13 <54227869+anupriya13@users.noreply.github.com> * Remove XAML dependency from IDL by defining local SnapAlignment enum Co-authored-by: anupriya13 <54227869+anupriya13@users.noreply.github.com> * Extract snap alignment conversion into separate function for better readability Co-authored-by: anupriya13 <54227869+anupriya13@users.noreply.github.com> * Revert changes to ScrollViewExample.js as requested Co-authored-by: anupriya13 <54227869+anupriya13@users.noreply.github.com> * Revert changes to ScrollViewComponentTest.test.ts as requested Co-authored-by: anupriya13 <54227869+anupriya13@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: anupriya13 <54227869+anupriya13@users.noreply.github.com>
509e4ca
to
f87e92f
Compare
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.
Please add a video recording, displaying how this prop works.
vnext/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp
Outdated
Show resolved
Hide resolved
vnext/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp
Outdated
Show resolved
Hide resolved
vnext/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp
Show resolved
Hide resolved
vnext/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp
Outdated
Show resolved
Hide resolved
vnext/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp
Outdated
Show resolved
Hide resolved
vnext/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp
Show resolved
Hide resolved
Add this case to scrollview/samples |
It's already added
|
Waiting on review since long time > assigned to @satkh for iteration 2507-02 |
Description
Type of Change
Why
Implement snapToAlignment property for ScrollView in Fabric
Resolves #13148
What
Implement snapToAlignment property for ScrollView in Fabric

https://reactnative.dev/docs/scrollview#snaptoalignment
Refer IOS implementation https://github.com/facebook/react-native/blob/618279508159191f2b11c0b20446f91e82a27abf/packages/react-native/React/Views/ScrollView/RCTScrollView.m#L833
Background
The
snapToAlignment
property was available in RNW Paper via ScrollViewManager but missing from the Fabric implementation, causing a parity gap between the two architectures.We came up with this implementation to ensure that snap points align correctly within the viewport depending on the desired alignment. Since snap positions are relative to the start edge by default, we subtract half the viewport size for center alignment or the full viewport size for end alignment. This way, when scrolling settles on a snap point, it appears at the right position in the visible area.
More context:
What is a snap point?
When the user scrolls or flicks the content, instead of stopping anywhere, the scroller will settle on the closest snap point, making the scrolling feel natural and intentional.
This is what m_snapToAlignment controls:
Start: snap position aligns to start of viewport
Center: snap position aligns to center of viewport
End: snap position aligns to end of viewport
Screenshots
Recording.2025-07-09.122123.mp4
Testing
Tested in playground and e2etestappfabric already added
Changes
Core Implementation
CompositionSwitcher.idl
to acceptsnapToAlignment
parameterScrollViewComponentView.cpp
with proper enum conversion from React Native to Windows typesChangelog
Should this change be included in the release notes: YES
Add a brief summary of the change to use in the release notes for the next release.
Implement snapToAlignment property for ScrollView in Fabric
Microsoft Reviewers: Open in CodeFlow