我使用一个<FlatList>
组件来显示一个简单的列表。
这个组件有用于onEndReached
的事件,但是我找不到与顶部相同的事件,比如onBeginningReached
事件。
如何检测到用户已滚动到<FlatList>
的最顶端
发布于 2020-03-09 14:42:01
为此,您可以使用onMomentumScrollEnd
支柱:
onMomentumScrollEnd={e => {
if (e.nativeEvent.contentOffset.y === 0) {
// do things
}
}}
我建议的是onMomentumScrollEnd
,而不是onScroll
,因为它的激发次数要少得多,对性能的影响也要小得多。
https://stackoverflow.com/questions/60602717
复制相似问题