在React Native中获取ScrollView的当前滚动位置 [英] Get current scroll position of ScrollView in React Native
本文介绍了在React Native中获取ScrollView的当前滚动位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在React Native中获取当前滚动位置或< ScrollView>
组件的当前页面?
Is it possible to get the current scroll position, or the current page of a <ScrollView>
component in React Native?
类似于:
<ScrollView
horizontal={true}
pagingEnabled={true}
onScrollAnimationEnd={() => {
// get this scrollview's current page or x/y scroll position
}}>
this.state.data.map(function(e, i) {
<ImageCt key={i}></ImageCt>
})
</ScrollView>
推荐答案
尝试。
<ScrollView onScroll={this.handleScroll} />
然后:
handleScroll: function(event: Object) {
console.log(event.nativeEvent.contentOffset.y);
},
这篇关于在React Native中获取ScrollView的当前滚动位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文