diff options
| author | Adam Soltys <[email protected]> | 2024-11-06 15:42:24 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-11-06 15:42:24 -0800 |
| commit | 3dfa3eb19dbe8ea03dc7a8ae21c3233e22a47264 (patch) | |
| tree | 5e8ec1934f5401ddeeb48cc2bf5502a1b2b6a131 /src/routes | |
| parent | c0590ecb322007790df1ef74a5088ceca486ba50 (diff) | |
| download | coinos-ui-3dfa3eb19dbe8ea03dc7a8ae21c3233e22a47264.tar.gz coinos-ui-3dfa3eb19dbe8ea03dc7a8ae21c3233e22a47264.zip | |
fix pagination
Diffstat (limited to 'src/routes')
| -rw-r--r-- | src/routes/(app)/payments/[...page]/+page.svelte | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/routes/(app)/payments/[...page]/+page.svelte b/src/routes/(app)/payments/[...page]/+page.svelte index 90245bb6..ba2e4992 100644 --- a/src/routes/(app)/payments/[...page]/+page.svelte +++ b/src/routes/(app)/payments/[...page]/+page.svelte @@ -128,8 +128,31 @@ } }; - const showPage = (i) => i < 6 || i >= pages.length - 6; - const isEllipsis = (i) => pages.length > 12 && i === 6; + $: showPage = (i) => { + const currentPage = parseInt(p); + const maxVisiblePages = 12; + + if (i === 0 || i === pages.length - 1) return true; + + let start = Math.max( + 1, + currentPage - Math.floor((maxVisiblePages - 4) / 2), + ); + let end = start + maxVisiblePages - 5; + + if (end >= pages.length - 1) { + end = pages.length - 2; + start = Math.max(1, end - (maxVisiblePages - 5)); + } + + return i >= start && i <= end; + }; + + $: isEllipsis = (i) => { + return ( + (i === 1 && !showPage(i)) || (i === pages.length - 2 && !showPage(i)) + ); + }; </script> <div class="space-y-5"> |
