Skip to content

Instantly share code, notes, and snippets.

@elzii
Created May 6, 2014 18:59
Show Gist options
  • Save elzii/79e5b9f53b169eef0649 to your computer and use it in GitHub Desktop.
Save elzii/79e5b9f53b169eef0649 to your computer and use it in GitHub Desktop.
leah slider
var tot = images.length,
c = 0, // current image (array key index)
duration = 150,
$hero_image = $('.hero-image'),
$slide_cap = $('#slideCaption');
function initSlide(){
$hero_image.css('background-image', images[c]);
$slide_cap.html(captions[c]);
}
function loadImage(){
$hero_image.animate({'opacity' : '0'}, duration);
setTimeout(function(){
$hero_image.css('background-image', images[c]);
$hero_image.animate({'opacity' : '1'}, duration);
}, duration);
$slide_cap.html(captions[c]);
};
initSlide(); // load 1 image
$('#prev, #next, #viewSlideshow').click(function(){
id= this.id==='next' ? c++ : c-- ;
c= c==-1 ? tot-1 : c%tot ;
loadImage();
hideHeaderElements();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment