Skip to content

Instantly share code, notes, and snippets.

@iErik
Created February 11, 2020 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iErik/3b5a8b88ca38b88a572ba8614bbe973c to your computer and use it in GitHub Desktop.
Save iErik/3b5a8b88ca38b88a572ba8614bbe973c to your computer and use it in GitHub Desktop.
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