Created
February 11, 2020 20:56
-
-
Save iErik/3b5a8b88ca38b88a572ba8614bbe973c to your computer and use it in GitHub Desktop.
This file contains 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
show() { | |
const base = this.localCurrentPage | |
const max = this.max | |
const factor = Math.ceil(max / 2) | |
const pgFrom = (base - factor) || 1 | |
const pgTo = base <= this.totalPages ? base + factor : this.totalPages | |
const result = Array.from({ length: max }, (e, i) => | |
pgFrom + max > this.totalPages | |
? (this.totalPages + 1) - (max - i) | |
: pgFrom < 0 ? i + 1 : pgFrom + i) | |
return result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment