react-nativereact-native-scrollview

How to recognize if element is on the screen using react native?


When user scrolling posts in my app i want recognize the current post the user is seeing now.


Solution

  • You can get y position on scroll from contentOffset

    <ScrollView
      ref={(s) => this.scrollview = s}
      onScroll={(event) => {console.log(event.nativeEvent.contentOffset.y)}}
      ...
    ></ScrollView>