This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

web/components: simplify Pagination

Signed-off-by: eti <eti@eti.tf>

-6
-6
web/src/lib/components/ui/Pagination.svelte
··· 31 31 const range = (from: number, to: number): number[] => 32 32 Array.from({ length: Math.max(to - from + 1, 0) }, (_, i) => from + i); 33 33 34 - // both ends, the current page and its two neighbours, and the two gaps 35 34 const SLOTS = 7; 36 35 37 - // the row is always SLOTS long once a gap is needed, so both gaps are permanent 38 - // residents. that is what lets the plate be placed from an index rather than 39 - // measured, and why paging the middle of a long range moves the numbers, not the row 40 36 export function paginate(page: number, count: number): PaginationItem[] { 41 37 if (count <= SLOTS) return range(1, count); 42 - // near either end a gap would hide fewer pages than the slots it costs, so the 43 - // window opens flush against that end and only the far gap is drawn 44 38 if (page < 4) return [...range(1, 5), "gap-end", count]; 45 39 if (page > count - 3) return [1, "gap-start", ...range(count - 4, count)]; 46 40 return [1, "gap-start", ...range(page - 1, page + 1), "gap-end", count];