I am building a header that animates/hides as the user scrolls down a Flatlist. Is there any way to find out the scroll position of the Flatlist in pixels?
I'm using react native 0.59.8. I've tried using onScroll hoping it passes a value to the callback - it doesn't. I've also tried onScrollBeginDrag, onScrollEndDrag and onMomentumScrollEnd.. None of them provide information of the current scroll position.
onSroll={(info)=>{console.log(info)}
I would expect to get some information about the scroll, but none is passed.
Use:
<FlatList onScroll={this.handleScrollView} />
e.g.
handleScrollView: function(event: Object) {
this.setState({ scrollPosition: event.nativeEvent.contentOffset.y });
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With