fix listview inefficiency for tail-fetching scenarios (part1)

Reviewed By: sahrens

Differential Revision: D2775226

fb-gh-sync-id: 13cc895d8cde4ab1baf527ab468d6c7b47158aef
This commit is contained in:
olivier notteghem 2015-12-21 08:40:52 -08:00 committed by facebook-github-bot-2
parent bfb4ef9ec8
commit 040909904c

View File

@ -37,6 +37,7 @@ var TimerMixin = require('react-timer-mixin');
var isEmpty = require('isEmpty');
var logError = require('logError');
var merge = require('merge');
var shallowEqual = require('shallowEqual');
var PropTypes = React.PropTypes;
@ -266,6 +267,8 @@ var ListView = React.createClass({
this._childFrames = [];
this._visibleRows = {};
this._prevRenderedRowsCount = 0;
this._sentEndForContentLength = null;
this._lastScrollPropertiesCheckedForPaging = null;
},
componentDidMount: function() {
@ -452,13 +455,6 @@ var ListView = React.createClass({
}
},
_setScrollVisibleLength: function(left, top, width, height) {
this.scrollProperties.visibleLength = !this.props.horizontal ?
height : width;
this._updateVisibleRows();
this._renderMoreRowsIfNeeded();
},
_maybeCallOnEndReached: function(event) {
if (this.props.onEndReached &&
this.scrollProperties.contentLength !== this._sentEndForContentLength &&
@ -479,6 +475,12 @@ var ListView = React.createClass({
return;
}
if (shallowEqual(this._lastScrollPropertiesCheckedForPaging, this.scrollProperties)) {
// distance from end of feed hasn't changed since last check, avoid paging twice..
return;
}
this._lastScrollPropertiesCheckedForPaging = {...this.scrollProperties};
var distanceFromEnd = this._getDistanceFromEnd(this.scrollProperties);
if (distanceFromEnd < this.props.scrollRenderAheadDistance) {
this._pageInNewRows();