Skip to content

Instantly share code, notes, and snippets.

@radar
Forked from gotjosh/gist:5315106
Last active December 15, 2015 20:00
Show Gist options
  • Save radar/5315139 to your computer and use it in GitHub Desktop.
Save radar/5315139 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