Skip to content

Commit

Permalink
fix: total pages less than maxDisplayPages
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackman99 authored Jul 8, 2024
1 parent c763ea4 commit 7983aba
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/ui/src/components/CPagination.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,13 @@
}
$: boundaryLeft = Math.floor(maxDisplayPages / 2)
$: displayPages = maxDisplayPages < pages ? maxDisplayPages : pages
$: pagesArray = Array.from({
length: maxDisplayPages < pages ? maxDisplayPages : pages,
length: displayPages,
}).map((_, i) => {
if (current <= boundaryLeft) return i + 1
if (current >= pages - boundaryLeft) return pages - maxDisplayPages + i + 1
if (current >= pages - boundaryLeft) return pages - displayPages + i + 1
return i <= boundaryLeft
? current - boundaryLeft + i
Expand Down

0 comments on commit 7983aba

Please sign in to comment.