mirror of
https://github.com/status-im/react-native.git
synced 2025-02-27 16:40:38 +00:00
fix listview inefficiency for tail-fetching scenarios (part1)
Reviewed By: sahrens Differential Revision: D2775226 fb-gh-sync-id: 13cc895d8cde4ab1baf527ab468d6c7b47158aef
This commit is contained in:
parent
bfb4ef9ec8
commit
040909904c
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user