Created
September 14, 2011 11:42
-
-
Save egrouse/1216376 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
jQuery( document ).ready( function(){ | |
jQuery( 'div#images img' ).first().addClass( 'selected' ); | |
jQuery( 'div#descriptions div' ).first().addClass( 'selected' ); | |
}); | |
var images = jQuery( 'div#rsb-slider #images img' ), | |
descs = jQuery( 'div#rsb-slider #descriptions div' ); | |
descs.mouseenter( function(){ | |
next_image = jQuery( this ).index() - 1; | |
switch_image( next_image ); | |
}); | |
function auto_slide() | |
{ | |
current = jQuery( 'div#images img.selected' ).index(); | |
if( current + 1 == images.length ) | |
{ the_image = 0; } | |
else | |
{ the_image = current + 1; } | |
switch_image( the_image ); | |
} | |
jQuery(function() { | |
setInterval( "auto_slide()", 5000 ); | |
}); | |
function switch_image( next_image ) | |
{ | |
current = jQuery( 'div#images img.selected' ); | |
jQuery( 'div#descriptions div.selected' ).removeClass( 'selected' ); | |
descs.slice( next_image, next_image + 1 ).addClass( 'selected' ); | |
current.removeClass( 'selected' ).fadeOut( 300, function(){ | |
images.slice( next_image, next_image + 1 ).fadeIn( 300 ).addClass( 'selected' ); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment