我试图帮助一位朋友,他的主页上有一个旋转窗格,图片不会在无限循环上滚动。他们滚动浏览,然后回滚到开头,然后重新开始。如何让这个'滑块'的JavaScript无限旋转图像?
这里是JavaScript片段,他提供的:
$(function() {
if ($('#customScroller').length != 0) { //check if we're on the right page
var width = $('#slider a').length;
$('#slider').width(width * 930); //give the slider the appropriate width
var count = 0;
initial slide position
function slide() {
if (count < (width - 1)) { //we want to check if at end of the slider
count++;
}
else {
count = 0;
}
var toMove = 0;
toMove = (-1 * (count * 930));
$('#slider').animate({
left: toMove
}, 1000, function() {
//complete
});
}
var s = window.setInterval(slide, 8500);
}
});
多少工作是把它简单地循环转换无限?
编辑:这里是网站:http://www.ralphshardwood.com
把它放在一个循环,并当它刷爆重置计数器。 – 2012-03-30 14:45:32