[fix] inverted VirtualizedList supports wheel events#2223
Closed
staltz wants to merge 1 commit intonecolas:masterfrom
Closed
[fix] inverted VirtualizedList supports wheel events#2223staltz wants to merge 1 commit intonecolas:masterfrom
staltz wants to merge 1 commit intonecolas:masterfrom
Conversation
58b7c2f to
6b13017
Compare
6b13017 to
98128d4
Compare
Contributor
Author
|
Updated the commit so that it passes |
Owner
|
Thanks! I think deltaX needs to be used if the scroll direction is horizontal. See the similar PR #1241 |
98128d4 to
c0431f0
Compare
Contributor
Author
|
Done (force pushed an update to the commit). I also removed |
Owner
|
Thanks. Included in 0.17.6 |
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
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.
Context
Mostly issue #995 but also in other repos:
Problem
The
scale(-1)hack in FlatList whenprops.invertedis true is pretty dirty, and causes some side effects of "flipping things upside down", such as the arithmetics in thewheelevent. (Note, scrolling with the trackpad was working well before this PR and is unaffected by this PR)I have spent some days trying alternative such as recyclerlistview, but they seem to work well only if all items are of the same layout dimensions. When you need items of variable height and the
invertedprop, FlatList (VirtualizedList) was more reliable, it has more consistent behavior. (recyclerlistview was giving sudden yanks during scrolling)Solution
Flip the math when handling the
wheelevent, in VirtualizedList, as an event listener setup in componentDidMount/componentWillUnmount. The code I'm submitting here has been thoroughly tested in my app Manyverse in the form of apatch-package: https://github.com/staltz/manyverse/blob/52d5bbfb334e238f7d993ac7c0d764c32aeddb05/patches/react-native-web%2B0.17.5.patchTests
yarn test