Skip to content

Instantly share code, notes, and snippets.

@olegdater
Last active August 25, 2018 13:10
Show Gist options
  • Save olegdater/0cc406413d391cb3b8c000f5bbe437a2 to your computer and use it in GitHub Desktop.
Save olegdater/0cc406413d391cb3b8c000f5bbe437a2 to your computer and use it in GitHub Desktop.
Is ScrollView close to bottom?
const isCloseToBottom = ({ layoutMeasurement, contentOffset, contentSize }) => {
const paddingToBottom = 20;
return layoutMeasurement.height + contentOffset.y >=
contentSize.height - paddingToBottom;
};
<ScrollView
style={styles.scrollViewContainer}
scrollEventThrottle={1000}
onScroll={({ nativeEvent }) => {
if (isCloseToBottom(nativeEvent)) {
this.onEndReached();
}
}}
>
</ScrollView>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment