Skip to content

Commit

Permalink
Prevent page number from incrementing early on very tall screens (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
latonv committed May 8, 2024
1 parent 121531f commit 6b25314
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/collection-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 6b25314

Please sign in to comment.