Skip to content

Instantly share code, notes, and snippets.

@gadzhimari
Last active November 29, 2017 09:38
Show Gist options
  • Save gadzhimari/6632e48d9ae04785a2b977d2dcc5a5c5 to your computer and use it in GitHub Desktop.
Save gadzhimari/6632e48d9ae04785a2b977d2dcc5a5c5 to your computer and use it in GitHub Desktop.
Calculation formula of prev and next slide
const images = ['1.jpg', '2.jpg', '3.jpg'];
const total = images.length;
const next = (current + 1) % total;
const prev = (current + (total - 1)) % total;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment