Skip to content

Instantly share code, notes, and snippets.

@infinitylabs
Created October 1, 2013 21:26
Show Gist options
  • Select an option

  • Save infinitylabs/6785376 to your computer and use it in GitHub Desktop.

Select an option

Save infinitylabs/6785376 to your computer and use it in GitHub Desktop.
Infinity Slider
//--------------------------------------------------------------------------//
//slider
rotateNext = function(){
jQuery('.top-image-container .featured').filter(':visible').fadeOut(1000,function(){
if(jQuery(this).next('div.featured').size()){
jQuery(this).next().fadeIn(1000);
}
else{
jQuery('.top-image-container .featured').eq(0).fadeIn(1000);
}
});
};
rotatePrev = function(){
jQuery('.top-image-container .featured').filter(':visible').fadeOut(1000,function(){
if(jQuery(this).prev('div.featured').size()){
jQuery(this).prev().fadeIn(1000);
} else{
jQuery('.top-image-container .featured').eq(jQuery('.top-image-container .featured').size()-1).fadeIn(1000);
}
});
};
rotateStart = function(){ //Rotation + Timing Event
play = setInterval(function(){ //Set timer - this will repeat itself every 10 seconds
rotateNext();
}, 10000); //Timer speed in milliseconds (10 seconds)
};
nextSlider = function(){
clearInterval(play); //Stop the rotation
rotateNext(); //Trigger rotation immediately
rotateStart(); // Resume rotation
return false; //Prevent browser jump to link anchor
};
prevSlider = function(){
clearInterval(play); //Stop the rotation
rotatePrev(); //Trigger rotation immediately
rotateStart(); // Resume rotation
return false; //Prevent browser jump to link anchor
};
rotateStart(); //Run function on launch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment