繁体   English   中英

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

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

当滚动指示器低于滚动视图中的特定视图时,我想隐藏绝对定位按钮。 任何帮助,将不胜感激。 我尝试使用 onscroll 方法和其他 inview 插件组合,但没有得到想要的结果。 任何帮助,将不胜感激。

 <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>}

为此,我建议使用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