Last active
August 25, 2018 13:10
-
-
Save olegdater/0cc406413d391cb3b8c000f5bbe437a2 to your computer and use it in GitHub Desktop.
Is ScrollView close to bottom?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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