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.

Revisions

  1. infinitylabs created this gist Oct 1, 2013.
    40 changes: 40 additions & 0 deletions infinity_slider.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    //--------------------------------------------------------------------------//
    //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