Jump to content

Image Slider - almost working but just a little more!


melting_dog

Recommended Posts

Hi all,

 

I am building an image slider with a timer. I have everything working except for the mechanism that makes the slider go back to the start when it reaches the end. I am sure I will figure that out but there is an IF statement thats giving me trouble.

 

Basically its meant to reset i and show the alert box IF i (the counter) is equal to the number of images (so i gets +1 for each image it shown). Troulble is its just not triggering. I just cant figure out why. Can anyone help?

 

 

Code is:

 

var totalImages = jQuery("#gallery > li").length,

imageWidth = jQuery("#gallery > li:first").outerWidth(true),

i = 1;

 

while(i < totalImages){  

                jQuery("#gallery").delay(4000).animate({left : "-=" + imageWidth + "px"});

 

if(i == totalImages){

alert('The End');

i = 1;

}

i++;

}

 

 

Thanks!

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.