Created
July 22, 2020 05:36
-
-
Save utimur/2e34da5fa45ed34d73c6a40da2a6362a to your computer and use it in GitHub Desktop.
Page creator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function createPages(pages, pagesCount, currentPage) { | |
if(pagesCount > 10) { | |
if(currentPage > 5) { | |
for (let i = currentPage-4; i <= currentPage+5; i++) { | |
pages.push(i) | |
if(i == pagesCount) break | |
} | |
} | |
else { | |
for (let i = 1; i <= 10; i++) { | |
pages.push(i) | |
if(i == pagesCount) break | |
} | |
} | |
} else { | |
for (let i = 1; i <= pagesCount; i++) { | |
pages.push(i) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment