简体   繁体   English

如何检测滚动是否低于滚动视图中的特定视图 React Native

[英]how to detect if scroll is below specific view in scrollview react native

I want to hide the absolute positioned button when scroll indicator is below a specific view in scrollview.当滚动指示器低于滚动视图中的特定视图时,我想隐藏绝对定位按钮。 any help would be appreciated.任何帮助,将不胜感激。 I tried using onscroll method and other inview plugin combination but I'm not getting the desired result.我尝试使用 onscroll 方法和其他 inview 插件组合,但没有得到想要的结果。 any help would be appreciated.任何帮助,将不胜感激。

 <ScrollView  style={{ width: deviceDimesions.width, alignSelf: 'center' }} showsVerticalScrollIndicator={true} bounces={false} nestedScrollEnabled={true}>
<View>View 1</View>
<View>View 2</View>
<View>View 3. (hide buttons when scroll reached at this view)</View>
<View>View 4</View>
</ScrollView>

{this.state.user && <View style={{ position: 'absolute', bottom: 10, backgroundColor: '#fff', padding: 15, width: deviceDimesions.width, alignSelf: 'center' }}>
<View>}

For this, i suggest to use IntersectionObserver API. It was solved here: Detect whether element is above or below the viewport on intersect leave with intersection observer为此,我建议使用IntersectionObserver API。它在这里解决了: Detect whether element is above or below the viewport on intersect leave with intersection observer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM