-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
Support platform customization of inverted VirtualizedList #32038
Conversation
This pull request was exported from Phabricator. Differential Revision: D30398027 |
|
Base commit: d3345f5 |
Summary: Pull Request resolved: #32038 This change slightly modifies VirtualizedList to better support platform customization of inverted behavior. For example, on react-native-windows, the transform approach to inverted breaks some scrolling input behaviors (see https://github.com/microsoft/react-native-windows/issue/4098). In react-native-windows, inverted behavior can be implemented using a combination of Yoga and platform native anchoring behaviors. When implemented this way, some assumptions in VirtualizedList are broken, namely that layouts of list items have monotonically increasing offsets on the scroll axis. Rather than entirely overhauling VirtualizedList to eliminate this assumption, a more trivial workaround is to invert the scroll and list item layout metrics in JS so they appear to be monotonically increasing for features like data loading and onEndReached events, and using raw metrics for features like scrollToIndex. We can accomplish most of this by overwriting the `_getScrollMetrics()` and `_getFrameMetrics()` functions in the platform VirtualizedList JS module. ## Changelog: [General][Added] - Support platform customization of inverted VirtualizedList Differential Revision: D30398027 fbshipit-source-id: 8ab3c2bdec29b7d9347fea1b89d034d1e7328393
This pull request was exported from Phabricator. Differential Revision: D30398027 |
@@ -1827,6 +1833,7 @@ class VirtualizedList extends React.PureComponent<Props, State> { | |||
|
|||
_getFrameMetricsApprox = ( | |||
index: number, | |||
useRawMetrics?: boolean, |
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.
would an enum be better here for revealing intention at the call sites, and for auto-completion (per Framework Design Guidelines 2nd ed)?
This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
ping? |
Summary:
This change slightly modifies VirtualizedList to better support platform customization of inverted behavior. For example, on react-native-windows, the transform approach to inverted breaks some scrolling input behaviors (see https://github.com/microsoft/react-native-windows/issue/4098).
In react-native-windows, inverted behavior can be implemented using a combination of Yoga and platform native anchoring behaviors. When implemented this way, some assumptions in VirtualizedList are broken, namely that layouts of list items have monotonically increasing offsets on the scroll axis.
Rather than entirely overhauling VirtualizedList to eliminate this assumption, a more trivial workaround is to invert the scroll and list item layout metrics in JS so they appear to be monotonically increasing for features like data loading and onEndReached events, and using raw metrics for features like scrollToIndex.
We can accomplish most of this by overwriting the
_getScrollMetrics()
and_getFrameMetrics()
functions in the platform VirtualizedList JS module.Changelog:
[General][Added] - Support platform customization of inverted VirtualizedList
Differential Revision: D30398027