Simple Image slider - no jump back
I have a very simple jquery slider that I made. Here is the code:
- var $distLeft = -764
- var $speedSlide = 800
- i=0
- $('.sp_box_content .galleryimg8').attr('src',$('.gallerybox8 a').attr('id'));
- if($.trim($('.gallerybox8').html()) != "") {max_sp_boxes = 8}
- galleryautoscroll();setInterval(galleryautoscroll,3500);
- function galleryautoscroll(){
- if(i==0){
- i=0
- $(".sp_box_list").animate({"margin-left":$distLeft*i},$speedSlide);
- i++
- }
- else {
- if (i==max_sp_boxes){
- i=0
- $(".sp_box_list").animate({"margin-left":$distLeft*i},$speedSlide);
- }
- $(".sp_box_list").animate({"margin-left":$distLeft*i},$speedSlide);
- i++
- }
- <div class="sp_box_content">
- <ul class="sp_box_list">
- <li><img class="galleryimg1" src="" /></li>
- <li><img class="galleryimg2" src="" /></li>
- <li><img class="galleryimg3" src="" /></li>
- <li><img class="galleryimg4" src="" /></li>
- <li><img class="galleryimg5" src="" /></li>
- <li><img class="galleryimg6" src="" /></li>
- <li><img class="galleryimg7" src="" /></li>
- <li><img class="galleryimg8" src="" /></li>
- </ul>
- </div>
I have a list of images. This javascript grabs the info that is displayed in a tag on the html. Then displays those images in the html. What I want is for at the end of the images to not have them jump back to the beginning, I want a never ending loop of the pictures. How do I do that?
I am also curious as to how I can randomize the order of the images.