Undocumented props. Why?

Anyway.

onMomentumScrollEnd will fire when the animation of the ScrollView stops.

For example, you can use the following snippet, to get the Y position of a <ScrollView ref="scrollView" />:

const RCTUIManager = require('NativeModules').UIManager
const sv = this.refs['scrollView'] as any
RCTUIManager.measure(sv.getInnerViewNode(), (...data) => {
  console.log(data[5])
})

And this is the order in which events of a ScrollView fire, in case you ever find yourself looking for answers that can’t be found in the official docs.

onTouchStart={() => console.log('onTouchStart')}
onTouchMove={() => console.log('onTouchMove')}
onTouchEnd={() => console.log('onTouchEnd')}
onScrollBeginDrag={() => console.log('onScrollBeginDrag')}
onScrollEndDrag={() => console.log('onScrollEndDrag')}
onMomentumScrollBegin={() => console.log('onMomentumScrollBegin')}
onMomentumScrollEnd={() => console.log('onMomentumScrollEnd')}

Reference:

http://stackoverflow.com/a/33924777/2621748

One thought on “React Native: get end position after scrolling a ScrollView

  1. Thanks for the insights! Have you submitted a PR to update the official docs to document these details? If not, it would be reeeeeeeaaaaaally great if you did. That’s where this sort of stuff gets the biggest bang for the buck.

Leave a Reply

Your email address will not be published. Required fields are marked *