Skip to content

Instantly share code, notes, and snippets.

@6r1d
Created November 13, 2013 04:20
Show Gist options
  • Save 6r1d/7443641 to your computer and use it in GitHub Desktop.
Save 6r1d/7443641 to your computer and use it in GitHub Desktop.
Centered pagination cases
case (position - radius > first_page && position + radius <= last_page):
pages = range_gen(position - radius, position + radius + 1, position);
break;
// - page is located near the left corner
case (position >= first_page && position <= first_page + radius):
pages = range_gen(first_page, first_page + (radius * 2) + 1, position);
break;
// - page is located near the right corner
case (position >= last_page - radius && position <= last_page):
pages = range_gen(last_page - (radius * 2), last_page + 1, position);
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment