简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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