我有一个旋转木马,它根据li
宽度向右移动。到达终点后,它会继续播放动画,直到最后一张图像是您唯一看到的图像。右边有一个空格。我将如何将其设置为循环,以便没有空白空间并且第一张图像再次出现?我向右移动 jquery 代码。
$('#right').click(function () {
if (currentItem === totalItems) {
$inner.animate({
right: '-=' + width * (totalItems-1) + 'px'
}, speed);
currentItem = 1;
} else {
$inner.animate({
right: '+=' + width
}, speed);
currentItem += 1;
}
});
因此,在到达结尾后,它会倒退到第一张图像。
编辑:如果你们想看,这是一个FIDDLE 。