0

I'm relatively new here, I was wondering if I can know when the user is scrolling to either right or left using ScrollView from react-native

As far as I know the method onScroll doesn't know where is the user scrolling to

  • Does this answer your question? [Finding out scroll direction in react-native listview/scrollview](https://stackoverflow.com/questions/36747541/finding-out-scroll-direction-in-react-native-listview-scrollview) – Bora Sumer Jan 07 '20 at 04:15

1 Answers1

0

Do check this out if you want to check left / right scroll :

 <ScrollView
        horizontal={true}
        onScroll={(event) =>{
    var currentOffset = event.nativeEvent.contentOffset.x;
        var direction = currentOffset > this.offset ? 'left' : 'right';
    alert(direction);
  }}
        >
        <Text style={{height:50}}>wiw</Text>
        <Text style={{height:50}}>wiw</Text>
        <Text style={{height:50}}>wiw</Text>
        <Text style={{height:50}}>wiw</Text>
        <Text style={{height:50}}>wiw</Text>
        <Text style={{height:50}}>wiw</Text>
        <Text style={{height:50}}>wiw</Text>
        <Text style={{height:50}}>wiw</Text>
        <Text style={{height:50}}>wiw</Text>
        <Text style={{height:50}}>wiw</Text>
        <Text style={{height:50}}>wiw</Text>

        </ScrollView>

Hope it helps .fee lfree for doubts

Gaurav Roy
  • 11,175
  • 3
  • 24
  • 45