-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix inverted cell style for inverted Animated.FlatList #3765
Merged
piaskowyk
merged 1 commit into
software-mansion:main
from
levibuzolic:fix-inverted-flatlist
Dec 19, 2022
Merged
Fix inverted cell style for inverted Animated.FlatList #3765
piaskowyk
merged 1 commit into
software-mansion:main
from
levibuzolic:fix-inverted-flatlist
Dec 19, 2022
Conversation
This file contains 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
Previously Animated.FlatList would show each item flipped when using the 'inverted' prop, this due to how 'inverted' works internally - it literally flips the ScrollView. In React Native they then apply a style to each cell item to restore the transform back to the correct way. This fix here works the same way.
levibuzolic
changed the title
Fix mirrored cell style for inverted Animated.FlatLists
Fix inverted cell style for inverted Animated.FlatList
Nov 13, 2022
piaskowyk
approved these changes
Dec 19, 2022
Hey 👋 Thanks for your PR! |
fluiddot
pushed a commit
to wordpress-mobile/react-native-reanimated
that referenced
this pull request
Jun 5, 2023
…ion#3765) ## Description `Animated.FlatList` currently presents each item flipped when using the `inverted` prop, this due to how the `inverted` props works internally (it literally flips the ScrollView). [In the React Native codebase](https://github.com/facebook/react-native/blob/29caed22cc1c9a426e524e498cf44cf18df0577e/Libraries/Lists/VirtualizedList.js#L1845-L1850) they then apply a style to each cell item to flip it back to the correct orientation. However this fix isn't applied to Reanimated's `FlatList` implementation because it overrides the `CellRendererComponent` prop. Fixes software-mansion#2769 ## Changes I've used the same fix from React Native to correct the implementation in Reanimated and included an example in the Example app so it's easy to verify if this gets regressed in the future. Before | After ---|--- ![Simulator Screen Recording - iPhone 8 - 2022-11-11 at 14 19 48](https://user-images.githubusercontent.com/721323/201256418-0edf01dc-c4df-4a87-8afd-364f0680631b.gif) | ![Simulator Screen Recording - iPhone 8 - 2022-11-11 at 14 18 16](https://user-images.githubusercontent.com/721323/201256429-2c0a216d-a61c-41a0-8528-654a73982b06.gif) ## Test code and steps to reproduce Check the `Inverted FlatList Example` in the Example app. ## Checklist - [x] Included code example that can be used to test this change - [x] ~Updated TS types~ - [x] ~Added TS types tests~ - [ ] Added unit / integration tests - [x] ~Updated documentation~ - [x] Ensured that CI passes
@piaskowyk sorry to resurrect this. Looks like in v3 (I am on 3.3.0) this needs to be reverted as it appears to be fixed elsewhere? Could we get a revert on this PR? |
@seba1342 hi, could you point me to the where it was fixed in react-native? |
Merged
github-merge-queue bot
pushed a commit
that referenced
this pull request
Oct 30, 2023
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect. --> ## Summary This PR changes how reanimated treats inverted `FlatLists`. In #3765 our implementation was changed to mimic the react-native behavior by assigning a special style that reverts the cell inversion (inverted FlatList flips the entire view and then flips back every cell). In react-native@0.72.4 the inversion style was [changed](facebook/react-native#38073) on android due to some performance issues. That change combined with our implementation was causing the cell to remain inverted on android (since both styles were being applied). This PR changes our implementation to instead allow the `CellRendererComponent` to receive a style prop, making react solely responsible for the cell inversion. ## Test plan Check whether the Inverted FlatList Example behaves properly on android. I tested the example on all rn versions from rn@0.69
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.
Description
Animated.FlatList
currently presents each item flipped when using theinverted
prop, this due to how theinverted
props works internally (it literally flips the ScrollView). In the React Native codebase they then apply a style to each cell item to flip it back to the correct orientation. However this fix isn't applied to Reanimated'sFlatList
implementation because it overrides theCellRendererComponent
prop.Fixes #2769
Changes
I've used the same fix from React Native to correct the implementation in Reanimated and included an example in the Example app so it's easy to verify if this gets regressed in the future.
Test code and steps to reproduce
Check the
Inverted FlatList Example
in the Example app.Checklist
Updated TS typesAdded TS types testsUpdated documentation