How can I implement a FlatList, in which I have items with dynamic heights and when I scroll to next item it should always snap on top of the screen.
Basically something like
https://www.youtube.com/watch?v=pTtxhuThMew&ab_channel=CatalinMiron
in this video but my items will be listed vertically and I wan’t to achieve this not once i click to a Pressable
but on scroll.
Let’s say you have list of images with different heights and each time you scroll, you wan’t the next item you scrolling to, snap to top of the screen.
2
Answers
meanwhile found a quick solution with following props
I thought this would work:
But snapToOffsets are absolute positions, so you need to accumulate the height/width:
Bringing it all together