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:
Spencer Ahrens 2015-11-04 11:25:47 -08:00 коммит произвёл facebook-github-bot-5
Родитель 6c11d18360
Коммит a4f7aa4853
1 изменённых файлов: 7 добавлений и 0 удалений

Просмотреть файл

@ -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);
},
});