I've made a small slideshow script to cycle through a list of images. The problem with it is selecting the current index during the next() and prev() functions.
When viewing the slideshow, it performs one too many next()'s resulting in no image being shown for one slide. The index is too high. When click prev(), it seems to sit at 0 index (no image there) for a few clicks then kicks back in at 7.
Here's the jQuery code
jQuery('.slideshow').css({'position': 'relative', 'width': 240, 'height': 263}).find('img').css('display', 'none');
jQuery('.slideshow').find('img').eq(startingSlide).css('display', 'block');
jQuery('.slideshow span').click(function()
{
if (jQuery(this).hasClass('span2'))
{
var currentSlide = jQuery('.slideshow img:visible').prevAll().length;
jQuery('.slideshow').find('img').eq(currentSlide)
.css('display', 'none').next('img').css('display', 'block').css({top: -300, left: 0}).animate({top: 0, left: 0}, 2000, 'easeOutBounce');
}
else
{
var currentSlide = jQuery('.slideshow img:visible').prevAll().length;
jQuery('.slideshow').find('img').eq(currentSlide)
.css('display', 'none').prev('img').css('display', 'block').css({top: 300, left: 0}).animate({top: 0, left: 0}, 2000, 'easeOutBounce');
}
});
Any idea on how to fix the indexes?