-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Implement snapToAlignment property for ScrollView in Fabric architecture #14830
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
Conversation
…nd prop handling Co-authored-by: anupriya13 <[email protected]>
…ementation Co-authored-by: anupriya13 <[email protected]>
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.
Remove changes in vnext/codegen files as not needed
Run "yarn change" prerelease, |
Co-authored-by: anupriya13 <[email protected]>
Removed the unnecessary changes from vnext/codegen files as requested. The core implementation for snapToAlignment is preserved. Commit b29a23a |
Co-authored-by: anupriya13 <[email protected]>
Completed all requested tasks: ✅ yarn change prerelease ✅ yarn lint:fix ✅ yarn format. Changes applied code formatting, added change file for prerelease version bump, and cleaned up codegen files. Commit 8b8a858 Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Remove all changes from vnext/codegen files |
Co-authored-by: anupriya13 <[email protected]>
Removed all changes from vnext/codegen files as requested. The core snapToAlignment implementation remains intact. Commit 9b8b8a9 Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
@@ -120,7 +120,7 @@ namespace Microsoft.ReactNative.Composition.Experimental | |||
void SetMaximumZoomScale(Single maximumZoomScale); | |||
void SetMinimumZoomScale(Single minimumZoomScale); | |||
Boolean Horizontal; | |||
void SetSnapPoints(Boolean snapToStart, Boolean snapToEnd, Windows.Foundation.Collections.IVectorView<Single> offsets); | |||
void SetSnapPoints(Boolean snapToStart, Boolean snapToEnd, Windows.Foundation.Collections.IVectorView<Single> offsets, Windows.UI.Xaml.Controls.SnapPointsAlignment snapToAlignment); |
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.
don't use xaml
Windows.UI.Xaml.Controls.
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.
Removed XAML dependency by defining a local SnapAlignment enum in the IDL file instead of using Windows.UI.Xaml.Controls.SnapPointsAlignment. Updated all related code to use the local enum. Commit a86cae6
Co-authored-by: anupriya13 <[email protected]>
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
…eadability Co-authored-by: anupriya13 <[email protected]>
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
|
Completed the requested tasks: ✅ yarn lint:fix - Successfully ran across all packages, no formatting issues found The first two tasks completed successfully with no changes needed to be committed. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
packages/@react-native/tester/js/examples/ScrollView/ScrollViewExample.js
Outdated
Show resolved
Hide resolved
@@ -86,4 +86,13 @@ describe('ScrollView Tests', () => { | |||
const dump = await dumpVisualTree('scroll_pressable_sticky_header'); | |||
expect(dump).toMatchSnapshot(); | |||
});*/ | |||
test('ScrollView snapToAlignment does not cause errors', async () => { |
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.
revert changes in this file
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.
Reverted changes in ScrollViewComponentTest.test.ts as requested. Commit b140442
Co-authored-by: anupriya13 <[email protected]>
Co-authored-by: anupriya13 <[email protected]>
* Implement snapToAlignment property for ScrollView in Fabric architecture (#14830) * Initial plan * Implement snapToAlignment support for Fabric ScrollView - interface and prop handling Co-authored-by: anupriya13 <[email protected]> * Add test support and UI for snapToAlignment in ScrollView Fabric implementation Co-authored-by: anupriya13 <[email protected]> * Remove unnecessary changes from vnext/codegen files Co-authored-by: anupriya13 <[email protected]> * Change files * Run yarn change prerelease, yarn lint:fix, and yarn format as requested Co-authored-by: anupriya13 <[email protected]> * Remove all changes from vnext/codegen files as requested Co-authored-by: anupriya13 <[email protected]> * Remove XAML dependency from IDL by defining local SnapAlignment enum Co-authored-by: anupriya13 <[email protected]> * Extract snap alignment conversion into separate function for better readability Co-authored-by: anupriya13 <[email protected]> * Revert changes to ScrollViewExample.js as requested Co-authored-by: anupriya13 <[email protected]> * Revert changes to ScrollViewComponentTest.test.ts as requested Co-authored-by: anupriya13 <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: anupriya13 <[email protected]> * Update ScrollViewComponentView.cpp * resolve comments * shorten string * Update CompositionContextHelper.cpp * yarn lint fix * fix testing issues --------- Co-authored-by: Copilot <[email protected]>
This PR implements the missing
snapToAlignment
property for Fabric ScrollView to achieve feature parity with the Paper implementation.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.Changes
Core Implementation
CompositionSwitcher.idl
to acceptsnapToAlignment
parameterScrollViewComponentView.cpp
with proper enum conversion from React Native to Windows typesConfigureSnapInertiaModifiers()
to adjust snap positions based on alignment:"start"
(Near): No adjustment - content snaps at natural positions"center"
(Center): Offsets positions by half viewport size - content centers in viewport"end"
(Far): Offsets positions by full viewport size - content aligns to end of viewportEnum Mapping
Testing Support
Usage
Developers can now use the
snapToAlignment
prop in Fabric ScrollView:Validation
ScrollViewProps.snapToAlignment
propertyFixes #13148.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
googlechromelabs.github.io
/usr/local/bin/node install.mjs
(dns block)https://api.github.com/repos/facebook/react-native/contents/flow-typed%2Fnpm
/usr/local/bin/node /home/REDACTED/work/react-native-windows/react-native-windows/vnext/node_modules/.bin/rnw-scripts lint --scope=react-native-windows
(http block)https://storage.googleapis.com/chrome-for-testing-public/130.0.6723.116/linux64/chrome-linux64.zip
/usr/local/bin/node install.mjs
(http block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.