react native - Detect ScrollView has reached the end - Stack Overflow
Sat Aug 15 2020 03:30:09 GMT+0000 (Coordinated Universal Time)
Saved by
@rdemo
import React from %27react%27;
import {ScrollView, Text} from %27react-native%27;
const isCloseToBottom = ({layoutMeasurement, contentOffset, contentSize}) => {
const paddingToBottom = 20;
return layoutMeasurement.height + contentOffset.y >=
contentSize.height - paddingToBottom;
};
const MyCoolScrollViewComponent = ({enableSomeButton}) => (
<ScrollView
onScroll={({nativeEvent}) => {
if (isCloseToBottom(nativeEvent)) {
enableSomeButton();
}
}}
scrollEventThrottle={400}
>
<Text>Here is very long lorem ipsum or something...</Text>
</ScrollView>
);
export default MyCoolScrollViewComponent;
content_copyCOPY
https://stackoverflow.com/questions/41056761/detect-scrollview-has-reached-the-end
Comments