簡體   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