Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect when at the top of a ListView

Tags:

react-native

I'm using a ListView component to display a simple list with section headers.

The ListView component has events for onEndReached but I could not find an onBeginningReached event.

How do you detect that a user has scrolled to the very top of the ListView?

like image 722
Davin Tryon Avatar asked Sep 11 '25 11:09

Davin Tryon


1 Answers

There is no such callback provided. Here is a workaround in React Native .. I assume ReactJS should have something similar

<ListView onScroll={this.handleScroll.bind(this)} ... />

handleScroll(event) { console.log(event.nativeEvent.contentOffset.y); }

You can see that the value printed when scrolled on top will be negative. See if that works and help..

like image 163
Nick Avatar answered Sep 14 '25 03:09

Nick