Merge pull request #10501 from Snuffleupagus/getVisibleElements-avoid-unnecessary-backtrack

In `getVisibleElements`, check `firstVisibleElementInd` rather than `numViews` before backtracking (PR 10443 follow-up)
This commit is contained in:
Tim van der Meij 2019-01-27 15:06:13 +01:00 committed by GitHub
commit d03d990e2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -446,7 +446,8 @@ function getVisibleElements(scrollEl, views, sortByVisibility = false,
// Please note the return value of the `binarySearchFirstItem` function when
// no valid element is found (hence the `firstVisibleElementInd` check below).
if (numViews > 0 && firstVisibleElementInd < numViews && !horizontal) {
if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews &&
!horizontal) {
// In wrapped scrolling (or vertical scrolling with spreads), with some page
// sizes, isElementBottomAfterViewTop doesn't satisfy the binary search
// condition: there can be pages with bottoms above the view top between