Created
May 6, 2014 18:59
-
-
Save elzii/79e5b9f53b169eef0649 to your computer and use it in GitHub Desktop.
leah slider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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