mirror of
https://github.com/status-im/react-native.git
synced 2025-01-15 20:15:11 +00:00
make onEndReached a little more robust
Summary: public Now if you scroll up out of the end threshold and then back down into it, onEndReached will get triggered again. This closes https://github.com/facebook/react-native/issues/1967 This also resets onEndReached when the data source changes. This would fix issues where the data source changes and onEndReached should fire again since the new data may have more pages, whereas the old data had reached the end and stopped. Reviewed By: jingc Differential Revision: D2610799 fb-gh-sync-id: f6cef513a42d4765514bf4bc55d9e31a760117f1
This commit is contained in:
parent
6c11d18360
commit
a4f7aa4853
@ -277,6 +277,7 @@ var ListView = React.createClass({
|
||||
|
||||
componentWillReceiveProps: function(nextProps) {
|
||||
if (this.props.dataSource !== nextProps.dataSource) {
|
||||
this._sentEndForContentLength = null;
|
||||
this.setState((state, props) => {
|
||||
var rowsToRender = Math.min(
|
||||
state.curRenderedRowsCount + props.pageSize,
|
||||
@ -592,6 +593,12 @@ var ListView = React.createClass({
|
||||
this._renderMoreRowsIfNeeded();
|
||||
}
|
||||
|
||||
if (this.props.onEndReached &&
|
||||
this._getDistanceFromEnd(this.scrollProperties) > this.props.onEndReachedThreshold) {
|
||||
// Scrolled out of the end zone, so it should be able to trigger again.
|
||||
this._sentEndForContentLength = null;
|
||||
}
|
||||
|
||||
this.props.onScroll && this.props.onScroll(e);
|
||||
},
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user