From 6b2531456ab75623a2c729b7826cac7bbe2d954a Mon Sep 17 00:00:00 2001 From: latonv <1619661+latonv@users.noreply.github.com> Date: Wed, 8 May 2024 14:02:44 -0700 Subject: [PATCH] Prevent page number from incrementing early on very tall screens (#372) --- src/collection-browser.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/collection-browser.ts b/src/collection-browser.ts index 56a7fe81..c5a929e1 100644 --- a/src/collection-browser.ts +++ b/src/collection-browser.ts @@ -1461,8 +1461,13 @@ export class CollectionBrowser if (this.isScrollingToCell) return; const { visibleCellIndices } = e.detail; if (visibleCellIndices.length === 0) return; - const lastVisibleCellIndex = - visibleCellIndices[visibleCellIndices.length - 1]; + + // For page determination, do not count more than a single page of visible cells, + // since otherwise patrons using very tall screens will be treated as one page + // further than they actually are. + const lastIndexWithinCurrentPage = + Math.min(this.pageSize, visibleCellIndices.length) - 1; + const lastVisibleCellIndex = visibleCellIndices[lastIndexWithinCurrentPage]; const lastVisibleCellPage = Math.floor(lastVisibleCellIndex / this.pageSize) + 1; if (this.currentPage !== lastVisibleCellPage) {