Title / Description
Code /**delta function is to set how the image slide—keep still for a while and move to next picture. *step function will be called many times until clearInterval() been called * currentImage * imageWidth is the currentImage position of ul * delta start from 0 to 1, delta * imageWidth is the pixels that changes **/ function slider(ul){ animate({ delay:17, duration: 3000, delta:function(p){return Math.max(0, -1 + 2 * p)}, step:function(delta){ ul.style.left = ‘-’ + parseInt(currentImage * imageWidth + delta * imageWidth) + ‘px’; }, callback:function(){ currentImage++; // if it doesn’t slied to the last image, keep sliding if(currentImage < imageNumber-1){ slider(ul); } // if current image it’s the last one, it slides back to the first one else{ var leftPosition = (imageNumber - 1) * imageWidth; // after 2 seconds, call the goBack function to slide to the first image setTimeout(function(){goBack(leftPosition)},2000); setTimeout(function(){slider(ul)}, 4000); } } }); }
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code