-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Implement snapToInterval property for ScrollView in Fabric #14829
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
Co-authored-by: anupriya13 <[email protected]>
…tion Co-authored-by: anupriya13 <[email protected]>
Run "yarn change" prerelease, |
Co-authored-by: anupriya13 <[email protected]>
All requested tasks completed in commit 5c63450:
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:
|
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 those are not needed
Co-authored-by: anupriya13 <[email protected]>
Removed changes in vnext/codegen files as requested in commit 8ba9bcd. These auto-generated files have been reverted to their original state. |
oldViewProps.snapToOffsets != newViewProps.snapToOffsets) { | ||
const auto snapToOffsets = winrt::single_threaded_vector<float>(); | ||
for (const auto &offset : newViewProps.snapToOffsets) { | ||
snapToOffsets.Append(static_cast<float>(offset)); |
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 remove this
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.
Restored the original inline snap points logic as requested. The code now preserves the existing logic for basic snapToOffsets cases and only uses the new updateSnapPoints() method when snapToInterval is involved. Commit 0424e18.
…rval support 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:
|
// Calculate the content size to determine how many intervals to create | ||
float contentLength = viewProps.horizontal | ||
? std::max(m_contentSize.width, m_layoutMetrics.frame.size.width) * m_layoutMetrics.pointScaleFactor | ||
: std::max(m_contentSize.height, m_layoutMetrics.frame.size.height) * m_layoutMetrics.pointScaleFactor; |
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.
Since this snappoint is dependent on the size, you'll have to ensure that this function is rerun when the size changes.. we should do a special InteractionTrackerInertiaRestingValue for the end snap point, which uses some references to the size so we dont need to constantly recalculate all of this.
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.
You're absolutely right about the performance concern. The current implementation recalculates all snap points on every content size change, which is inefficient.
I'll implement the optimization using InteractionTrackerInertiaRestingValue
with expression animations (similar to how snapToEnd
works in CompositionContextHelper.cpp). This will let the composition system dynamically calculate snap points based on size references rather than pre-calculating them.
Working on this now.
Co-authored-by: anupriya13 <[email protected]>
This PR implements the missing
snapToInterval
property for ScrollView in the React Native Windows Fabric (new architecture) implementation.Problem
The
snapToInterval
property was available in the Paper implementation viaScrollViewManager.cpp
but was missing from the Fabric implementation inScrollViewComponentView.cpp
. This meant that developers using the new architecture couldn't use interval-based snapping behavior.Solution
Added comprehensive support for
snapToInterval
that:updateProps()
to check forsnapToInterval
changes alongside existing snap propertiesupdateSnapPoints()
helper method that converts interval values to discrete snap point offsetsupdateContentVisualSize()
to recalculate snap points when content size changessnapToOffsets
takes priority oversnapToInterval
Implementation Details
Key Features
pointScaleFactor
snapToStart
,snapToEnd
,snapToAlignment
Example Usage
Testing
Fixes #13150.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.