Skip to content

Instantly share code, notes, and snippets.

@gotjosh
Last active December 15, 2015 19:59
Show Gist options
  • Save gotjosh/5315106 to your computer and use it in GitHub Desktop.
Save gotjosh/5315106 to your computer and use it in GitHub Desktop.
var totalPages = 50, buttons = 3;
var currentPage = lowerLimit = upperLimit = Math.min(50, totalPages);
for (var b = 1; b < buttons && b < totalPages;) {
if (lowerLimit > 1 ) { lowerLimit--; b++; }
if (b < buttons && upperLimit < totalPages) { upperLimit++; b++; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment