Skip to content

Instantly share code, notes, and snippets.

@eksana
Created July 26, 2016 15:48
Show Gist options
  • Save eksana/f3f60d599072f1d58b4b9b58b9c7cfc5 to your computer and use it in GitHub Desktop.
Save eksana/f3f60d599072f1d58b4b9b58b9c7cfc5 to your computer and use it in GitHub Desktop.
galleryJS
var Gallery = new Object();
window.onload= function()
{
Gallery.Images = ['istockphoto_14149033.jpg', 'istockphoto_14232771.jpg', 'istockphoto_14667148.jpg'];
Gallery.CurrentIndex = 0;
Gallery._loopInterval = setInterval(Gallery.Next, 2500);
};
Gallery.Next = function()
{
if(Gallery.CurrentIndex < (Gallery.Images.length-1))
{
Gallery.CurrentIndex++;
}
else
{
Gallery.CurrentIndex = 0;
}
Gallery.Display();
};
Gallery.Prev = function()
{
if(Gallery.CurrentIndex > 0)
{
Gallery.CurrentIndex--;
}
else
{
Gallery.CurrentIndex = (Gallery.Images.length-1);
}
Gallery.Display();
};
Gallery.Display = function()
{
var photoGallery = document.getElementById('photo-gallery');
var currentImage = Gallery.Images[Gallery.CurrentIndex];
photoGallery.src = "../assets/img/"+currentImage;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment