You can try something like this, it is actually a plugin that I wrote for reuse, but you can extract it from the plugin form as shown below, you just need to add the correct elements and change the links to the elements, I think that it is currently a vertical scroll, but is easy to change:
function initInfiniteScroll(){ var $carousel, $prevTrigger, $nextTrigger, itemHeight; $carousel = $('#alternate-views'); $prevTrigger = $('.scroll-up'); $nextTrigger = $('.scroll-down'); itemHeight = 106; $allItems = $carousel.children().clone(); $allItems.appendTo($carousel); $allItems.prependTo($carousel); $prevTrigger.click(function() { scrollCarousel('up'); return false; }); $nextTrigger.click(function() { scrollCarousel(); return false; }); function scrollCarousel(direction) { if (direction == 'up') { $carousel.animate({ 'top': '+=' + itemHeight },1000,function(){ $carousel.children(':last').clone().prependTo($carousel); $carousel.children(':last').remove(); $carousel.css({'top':'-' + itemHeight + 'px'}); }); } else { $carousel.animate({ 'top': '-=' + itemHeight },1000,function(){ $carousel.children(':first').clone().appendTo($carousel); $carousel.children(':first').remove(); $carousel.css({'top':'-' + itemHeight + 'px'}); }); } } }
This clones the entire load and also places it on both sides of the original scroller - but you can remove it, also if you use jquery 1.4+, you can output the cloning and disconnect and re-add the elements instead as you scroll.
Also - if you want to make setTimeout, just use the content from the click function and place a timer around it. Hope this helps.
Jamie
source share