diff --git a/packages/virtualized-lists/Lists/VirtualizedList.js b/packages/virtualized-lists/Lists/VirtualizedList.js index 9f950916a2dfc0..8304aef4196e61 100644 --- a/packages/virtualized-lists/Lists/VirtualizedList.js +++ b/packages/virtualized-lists/Lists/VirtualizedList.js @@ -1219,7 +1219,7 @@ class VirtualizedList extends StateSafePureComponent { zoomScale: 1, }; _scrollRef: ?React.ElementRef = null; - _sentStartForContentLength = 0; + _sentStartForFirstVisibleItemKey: ?string = null; _sentEndForContentLength = 0; _updateCellsToRenderBatcher: Batchinator; _viewabilityTuples: Array = []; @@ -1546,22 +1546,21 @@ class VirtualizedList extends StateSafePureComponent { } // Next check if the user just scrolled within the start threshold - // and call onStartReached only once for a given content length, - // and only if onEndReached is not being executed + // and call onStartReached only once for a given first visible item if ( onStartReached != null && this.state.cellsAroundViewport.first === 0 && isWithinStartThreshold && - this._listMetrics.getContentLength() !== this._sentStartForContentLength + this.state.firstVisibleItemKey !== this._sentStartForFirstVisibleItemKey ) { - this._sentStartForContentLength = this._listMetrics.getContentLength(); + this._sentStartForFirstVisibleItemKey = this.state.firstVisibleItemKey; onStartReached({distanceFromStart}); } // If the user scrolls away from the start or end and back again, // cause onStartReached or onEndReached to be triggered again if (!isWithinStartThreshold) { - this._sentStartForContentLength = 0; + this._sentStartForFirstVisibleItemKey = null; } if (!isWithinEndThreshold) { this._sentEndForContentLength = 0;