I'm trying to create an endless slideshow of images that does as follows:
- Slides the images across a window
- When the last image is reached, it begins from the start of the images
Here is my current code:
var direction = '-';
function doScroll()
{
$('#products ul').animate({left: direction + '500'}, 5000, function()
{
if (direction == '-')
{
$('#products li:first').before($('#products li:last'));
}
else
{
$('#products li:last').after($('#products li:first'));
}
});
}
$(document).ready(function()
{
$('#products ul').css({'width': $('#products ul li').length * 185});
plzscroll = setInterval("doScroll()", 1000);
});
The reason for setInterval() is to create an endless animation.
According to Firebug, the UL get scrolled 500px to the left and then stops... The LI's successfully get moved around, however. The first image gets placed at the end of the slideshow and continues on.
All I need is to figure out why the animation doesn't continue sliding UL.