@@ -609,12 +609,8 @@ class VirtualizedList extends StateSafePureComponent<
609609 pendingScrollUpdateCount : number ,
610610 ) : { first : number , last : number } {
611611 const { data, getItemCount} = props ;
612- const onEndReachedThreshold = onEndReachedThresholdOrDefault (
613- props . onEndReachedThreshold ,
614- ) ;
615- const { offset, visibleLength} = this . _scrollMetrics ;
612+ const { visibleLength} = this . _scrollMetrics ;
616613 const contentLength = this . _listMetrics . getContentLength ( ) ;
617- const distanceFromEnd = contentLength - visibleLength - offset ;
618614
619615 // Wait until the scroll view metrics have been set up. And until then,
620616 // we will trust the initialNumToRender suggestion
@@ -624,43 +620,27 @@ class VirtualizedList extends StateSafePureComponent<
624620 : cellsAroundViewport;
625621 }
626622
627- let newCellsAroundViewport : { first : number , last : number } ;
628- if ( props . disableVirtualization ) {
629- const renderAhead =
630- distanceFromEnd < onEndReachedThreshold * visibleLength
631- ? maxToRenderPerBatchOrDefault ( props . maxToRenderPerBatch )
632- : 0 ;
633-
634- newCellsAroundViewport = {
635- first : 0 ,
636- last : Math . min (
637- cellsAroundViewport . last + renderAhead ,
638- getItemCount ( data ) - 1 ,
639- ) ,
640- } ;
641- } else {
642- // If we have a pending scroll update, we should not adjust the render window as it
643- // might override the correct window.
644- if ( pendingScrollUpdateCount > 0 ) {
645- return cellsAroundViewport . last >= getItemCount ( data )
646- ? VirtualizedList . _constrainToItemCount ( cellsAroundViewport , props )
647- : cellsAroundViewport ;
648- }
649-
650- newCellsAroundViewport = computeWindowedRenderLimits (
651- props ,
652- maxToRenderPerBatchOrDefault ( props . maxToRenderPerBatch ) ,
653- windowSizeOrDefault ( props . windowSize ) ,
654- cellsAroundViewport ,
655- this . _listMetrics ,
656- this . _scrollMetrics ,
657- ) ;
658- invariant (
659- newCellsAroundViewport . last < getItemCount ( data ) ,
660- 'computeWindowedRenderLimits() should return range in-bounds' ,
661- ) ;
623+ // If we have a pending scroll update, we should not adjust the render window as it
624+ // might override the correct window.
625+ if ( pendingScrollUpdateCount > 0 ) {
626+ return cellsAroundViewport . last >= getItemCount ( data )
627+ ? VirtualizedList . _constrainToItemCount ( cellsAroundViewport , props )
628+ : cellsAroundViewport;
662629 }
663630
631+ const newCellsAroundViewport = computeWindowedRenderLimits (
632+ props ,
633+ maxToRenderPerBatchOrDefault ( props . maxToRenderPerBatch ) ,
634+ windowSizeOrDefault ( props . windowSize ) ,
635+ cellsAroundViewport ,
636+ this . _listMetrics ,
637+ this . _scrollMetrics ,
638+ ) ;
639+ invariant (
640+ newCellsAroundViewport . last < getItemCount ( data ) ,
641+ 'computeWindowedRenderLimits() should return range in-bounds' ,
642+ ) ;
643+
664644 if ( this . _nestedChildLists . size ( ) > 0 ) {
665645 // If some cell in the new state has a child list in it, we should only render
666646 // up through that item, so that we give that list a chance to render.
@@ -1015,12 +995,6 @@ class VirtualizedList extends StateSafePureComponent<
1015995
1016996 for ( const section of renderRegions ) {
1017997 if ( section . isSpacer ) {
1018- // Legacy behavior is to avoid spacers when virtualization is
1019- // disabled (including head spacers on initial render).
1020- if ( this . props . disableVirtualization ) {
1021- continue ;
1022- }
1023-
1024998 // Without getItemLayout, we limit our tail spacer to the _highestMeasuredFrameIndex to
1025999 // prevent the user for hyperscrolling into un-measured area because otherwise content will
10261000 // likely jump around as it renders in above the viewport.
0 commit comments