From 32d05d71dc2e2ba3cd4b222c31f2957ac66d9900 Mon Sep 17 00:00:00 2001 From: leejinseok Date: Thu, 20 Feb 2020 12:26:57 +0900 Subject: [PATCH] update --- src/front/src/utils/paginationUtil2.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/front/src/utils/paginationUtil2.js b/src/front/src/utils/paginationUtil2.js index b37d91e..3186168 100644 --- a/src/front/src/utils/paginationUtil2.js +++ b/src/front/src/utils/paginationUtil2.js @@ -22,24 +22,24 @@ export default function (currentPage, totalPage, chapterSize = 5) { // currentPage 2 => left -1, right +3 const halfOfChapterSize = Math.ceil(chapterSize / 2); - const halfOfLastChapter = totalPage - halfOfChapterSize + 1; + const halfOfLastChapter = totalPage - halfOfChapterSize; let extra = chapterSize - 1; let start; let end; + if (currentPage < halfOfChapterSize) { start = currentPage + (1 - currentPage); end = currentPage + halfOfChapterSize + (halfOfChapterSize - currentPage); } else if (currentPage > halfOfLastChapter) { - // halfOfLastChapter = 14; - extra = extra - (totalPage - currentPage); + let remainExtra = extra - (totalPage - currentPage); start = currentPage + (totalPage - currentPage); - end = currentPage - extra; + end = currentPage - remainExtra; } else { start = currentPage - extra / 2; end = currentPage + (extra / 2); - console.log(start,end); + end++; } // currentPage 12