Please sign in to comment.
support sticky headers
Summary: This adds support for both automagical sticky section headers in `SectionList` as well as the more free-form `stickyHeaderIndices` on `FlatList` or `VirtualizedList`. The basic concept is to take the initial `stickySectionHeaders` and remap them to the indices corresponding to the mounted subset in the render window. The main trick here is that the currently stuck header might itself be outside of the render window, so we need to search the gap to see if that's the case and render it (with spacers above and below it instead of one big spacer). In the `SectionList` we simply pre-compute the sticky headers at the same time as when we scan the sections to determine the flattened length and pass those to `VirtualizedList`. This also requires some updates to `ScrollView` to work in the churny environment of `VirtualizedList`. We propogate the keys on the children to the animated wrappers so that as items are removed and the indices of the remaining items change, react can keep proper track of them. We also fix the scroll back case where new headers are rendered from the top down and aren't updated with the `setNextLayoutY` callback because the `onLayout` call for the next header happened before it was mounted. This is done by just tracking all the layout values in a map and providing them to the sticky components at render time. This might also improve perf a little by property configuring the animations syncronously instead of waiting for the `onLayout` callback. We also need to protect against stale onLayout callbacks and other fun stuff. == Test Plan == https://www.facebook.com/groups/react.native.community/permalink/940332509435661/ Scroll a lot with and without debug mode on. Make sure spinner still spins and there are no crashes (lots of crashes during development due to the animated configuration being non-monotonic if anything stale values get through). Also made sure that tapping a row to change it's height would properly update the animation configurations so the collision point would still be correct. Reviewed By: yungsters Differential Revision: D4695065 fbshipit-source-id: 855c4e31c8f8b450d32150dbdb2e07f1a9f9f98e
- Loading branch information...
Showing with 204 additions and 81 deletions.
- +14 −1 Examples/UIExplorer/js/SectionListExample.js
- +55 −30 Libraries/Components/ScrollView/ScrollView.js
- +21 −8 Libraries/Components/ScrollView/ScrollViewStickyHeader.js
- +20 −7 Libraries/CustomComponents/Lists/SectionList.js
- +64 −20 Libraries/CustomComponents/Lists/VirtualizedList.js
- +11 −12 Libraries/CustomComponents/Lists/VirtualizedSectionList.js
- +4 −0 Libraries/CustomComponents/Lists/__tests__/__snapshots__/FlatList-test.js.snap
- +15 −3 Libraries/CustomComponents/Lists/__tests__/__snapshots__/SectionList-test.js.snap
Oops, something went wrong.