-
Notifications
You must be signed in to change notification settings - Fork 1.2k
PagingEnabled Parity for Fabric ScrollView #15341
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
Open
Nitin-100
wants to merge
6
commits into
microsoft:main
Choose a base branch
from
Nitin-100:nitin/parity-fabric/scrollview-pagingenabled
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
PagingEnabled Parity for Fabric ScrollView #15341
Nitin-100
wants to merge
6
commits into
microsoft:main
from
Nitin-100:nitin/parity-fabric/scrollview-pagingenabled
+293
−166
Conversation
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
- Add pagingEnabled boolean member to CompScrollerVisual - Implement PagingEnabled() method in IScrollVisual interface - Generate viewport-sized snap points when pagingEnabled=true - Wire up pagingEnabled prop in ScrollViewComponentView::updateProps() - Achieves parity with Paper ScrollView pagingEnabled support
- Added bool m_pagingEnabled member to CompScrollerVisual - Implemented PagingEnabled() method in IScrollVisual interface - Generate viewport-sized snap points when pagingEnabled=true - Wired up prop handling in ScrollViewComponentView - snapToOffsets disables pagingEnabled (matches Paper/iOS/Android behavior) - Excludes snapToEnd when pagingEnabled to avoid conflicts - Validates viewport size before generating snap points - Reconfigures snap points when size changes and paging is enabled Achieves full parity with Paper XAML and cross-platform React Native behavior.
Added complete snap point parity with Paper/iOS/Android: 1. pagingEnabled: Snaps to viewport-size intervals - Already implemented in previous commit - Full page-by-page scrolling behavior 2. snapToInterval: Snaps to fixed interval multiples - More flexible than pagingEnabled - Works with any interval value - Generates snap points at: 0, interval, 2*interval, 3*interval, ... maxScroll 3. snapToAlignment: Controls snap point alignment - Values: 'start' (Near), 'center' (Center), 'end' (Far) - Only applies when snapToInterval is set - Start: no offset (default) - Center: offset = -viewport/2 - End: offset = -viewport Priority hierarchy matches React Native official behavior: - snapToOffsets (highest) > snapToInterval > pagingEnabled > snapToStart/snapToEnd Implementation: - Added SnapPointsAlignment enum to CompositionSwitcher.idl - Added m_snapToInterval and m_snapToAlignment members to CompScrollerVisual - Implemented SnapToInterval() and SnapToAlignment() methods - Updated ConfigureSnapInertiaModifiers() with priority-based snap point generation - Wired props in ScrollViewComponentView::updateProps() - snapToOffsets disables both snapToInterval and pagingEnabled Matches Paper's SnapPointManagingContentControl behavior where: - GetRegularSnapPoints() returns m_interval when set - SnapToOffsets() sets m_interval = 0 (disables it) - XAML SnapPointsAlignment maps to: Near=start, Center=center, Far=end
208cc0f to
f357995
Compare
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
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.
PR Description: ScrollView Snap Point Parity for Fabric
Description
Type of Change
Why
The Fabric Composition architecture was missing support for snap point properties in ScrollView components. Paper XAML fully supports these properties through
SnapPointManagingContentControl, enabling various snapping behaviors for improved scroll UX.This created feature gaps where:
pagingEnabled)snapToInterval)snapToAlignment)snapToOffsets,snapToStart,snapToEndbut lacked the convenient interval-based optionsWhat
Implemented complete snap point parity in Fabric ScrollView to match Paper XAML, iOS, and Android behavior:
1. pagingEnabled Property:
2. snapToInterval Property:
pagingEnabled- works with any interval value3. snapToAlignment Property:
'start'(default),'center','end'snapToIntervalis setPriority Hierarchy (matches iOS/Android/Paper):
Technical Implementation:
This implementation uses Fabric's existing InteractionTracker-based snap point system, generating
InteractionTrackerInertiaRestingValueinstances for each snap position with appropriate condition and resting expressions.Screenshots
No screenshots needed. Implements standard scroll snapping behavior matching Paper/iOS/Android.
Testing
Will be tested in playground-composition.sln:
pagingEnabled Testing:
Horizontal paging:
<ScrollView horizontal pagingEnabled>Vertical paging:
<ScrollView pagingEnabled>snapToInterval Testing:
Fixed interval snapping:
<ScrollView snapToInterval={100}>With snapToAlignment="start" (default):
<ScrollView snapToInterval={100} snapToAlignment="start">With snapToAlignment="center":
<ScrollView snapToInterval={100} snapToAlignment="center">With snapToAlignment="end":
<ScrollView snapToInterval={100} snapToAlignment="end">Priority Testing:
snapToOffsets overrides snapToInterval:
<ScrollView snapToInterval={100} snapToOffsets={[50, 150, 300]}>snapToOffsets overrides pagingEnabled:
<ScrollView pagingEnabled snapToOffsets={[50, 150, 300]}>snapToInterval overrides pagingEnabled:
<ScrollView pagingEnabled snapToInterval={100}>Edge Cases:
Content smaller than viewport:
Content not exact multiple:
Dynamic resizing:
Compare with Paper:
Changelog
Should this change be included in the release notes: yes
Implemented snap point parity for Fabric ScrollView:
Matches iOS/Android/Paper behavior with correct priority hierarchy: snapToOffsets > snapToInterval > pagingEnabled. Users can now use all standard React Native scroll snapping features in Fabric architecture.
Related Work
SnapPointManagingContentControlwithGetRegularSnapPoints()returning interval/viewport sizeInteractionTrackerInertiaRestingValuefor each snap positionBreaking Changes
None. These are additive features with sensible defaults:
pagingEnableddefaults tofalsesnapToIntervaldefaults to0(disabled)snapToAlignmentdefaults to'start'(Near)Existing ScrollView behavior unchanged.
Additional Notes
React Native Official Behavior (from reactnative.dev):
pagingEnabled:
snapToInterval:
snapToAlignment:
'start': Align snap at left (horizontal) or top (vertical)'center': Align snap in center'end': Align snap at right (horizontal) or bottom (vertical)snapToOffsets:
Implementation Notes: