如何知道 FlatList 中滚动(向上或向下)的状态? [英] How to know the state of scroll (up or down) in FlatList?
本文介绍了如何知道 FlatList 中滚动(向上或向下)的状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何知道FlatList中的滚动状态?喜欢向上滚动还是向下滚动?我想知道向上或向下滚动以显示或隐藏 FlatList 中的标题的状态.
How to know the state of the scroll in FlatList? Like scrolling up or scrolling down? I want to know the state scrolling up or down to show or hide header in FlatList.
推荐答案
使用 onScroll 属性如下.(官方)
Use the onScroll property as below. (Official)
<ScrollView onScroll={this._onScroll} />
_onScroll = (event) {
console.log(event.nativeEvent.contentOffset.y);
},
为了保证得到滚动最后一帧的值,需要设置一个属性scrollEventThrottle={16}
.
And for guarantee getting the value of scrolling's last frame, you need to set a property scrollEventThrottle={16}
.
这篇关于如何知道 FlatList 中滚动(向上或向下)的状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文