Skip to content

Instantly share code, notes, and snippets.

@tomraithel
Created November 16, 2012 08:28
Show Gist options
  • Save tomraithel/4085466 to your computer and use it in GitHub Desktop.
Save tomraithel/4085466 to your computer and use it in GitHub Desktop.
JS: normalize a page number to match a valid page in a looping carrousel / slider
_getNormalizedPage: function(page) {
if(page < 0) {
return this.pages.length + (page % this.pages.length)
}
return page % this.pages.length;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment