Skip to content

Instantly share code, notes, and snippets.

@juanlatorre
Created September 26, 2019 13:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanlatorre/bbb19fd397eb1f84d2cb57bd4c49227f to your computer and use it in GitHub Desktop.
Save juanlatorre/bbb19fd397eb1f84d2cb57bd4c49227f to your computer and use it in GitHub Desktop.
const imageData = [ 'image1.png', 'img2.png', 'img3.png' ];
const currentImage = 0;
const handleImageChange = (direction) => {
if (direction == 'forward')
currentImage = (currentImage + 1) % imageData.length;
else
currentImage = (currentImage - 1 + imageData.length) % imageData.length;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment