diff --git a/Libraries/CustomComponents/ListView/ListView.js b/Libraries/CustomComponents/ListView/ListView.js index 4554eb6812..834de83a0a 100644 --- a/Libraries/CustomComponents/ListView/ListView.js +++ b/Libraries/CustomComponents/ListView/ListView.js @@ -452,10 +452,23 @@ var ListView = React.createClass({ this._updateVisibleRows(childFrames); }, + _maybeCallOnEndReached: function(event) { + if (this.props.onEndReached && + this.scrollProperties.contentLength !== this._sentEndForContentLength && + this._getDistanceFromEnd(this.scrollProperties) < this.props.onEndReachedThreshold && + this.state.curRenderedRowsCount === this.props.dataSource.getRowCount()) { + this._sentEndForContentLength = this.scrollProperties.contentLength; + this.props.onEndReached(event); + return true; + } + return false; + }, + _renderMoreRowsIfNeeded: function() { if (this.scrollProperties.contentLength === null || this.scrollProperties.visibleLength === null || this.state.curRenderedRowsCount === this.props.dataSource.getRowCount()) { + this._maybeCallOnEndReached(); return; } @@ -570,14 +583,7 @@ var ListView = React.createClass({ isVertical ? 'y' : 'x' ]; this._updateVisibleRows(e.nativeEvent.updatedChildFrames); - var nearEnd = this._getDistanceFromEnd(this.scrollProperties) < this.props.onEndReachedThreshold; - if (nearEnd && - this.props.onEndReached && - this.scrollProperties.contentLength !== this._sentEndForContentLength && - this.state.curRenderedRowsCount === this.props.dataSource.getRowCount()) { - this._sentEndForContentLength = this.scrollProperties.contentLength; - this.props.onEndReached(e); - } else { + if (!this._maybeCallOnEndReached(e)) { this._renderMoreRowsIfNeeded(); }