feat(getPageNumber - fixed and applied)
This commit is contained in:
@@ -5,16 +5,17 @@ export function getPageNumbers(current: number, total: number, maxButtons = 7) {
|
||||
return pages;
|
||||
}
|
||||
|
||||
const half = Math.floor(maxButtons / 2);
|
||||
let start = Math.max(1, current - half);
|
||||
let end = Math.min(total, current + half);
|
||||
const delta = 2;
|
||||
const start = Math.max(2, current - delta);
|
||||
const end = Math.min(total - 1, current + delta);
|
||||
|
||||
if (start === 1) end = Math.min(total, maxButtons);
|
||||
if (end === total) start = Math.max(1, total - maxButtons + 1);
|
||||
pages.push(1);
|
||||
if (start > 2) pages.push("...");
|
||||
|
||||
if (start > 1) pages.push(1, "...");
|
||||
for (let i = start; i <= end; i++) pages.push(i);
|
||||
if (end < total) pages.push("...", total);
|
||||
|
||||
if (end < total - 1) pages.push("...");
|
||||
if (total > 1) pages.push(total);
|
||||
|
||||
return pages;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user