function animate(offset) {
animated = true;
var newLeft = parseInt(list.style.left) + offset;
var time = 300; // 位移总时间
var interval = 10; // 位移间隔事件时间
var speed = offset / (time / interval); // 位移速度
function go() {
if ((speed < 0 && parseInt(list.style.left) > newLeft) || (speed > 0 && parseInt(list.style.left) < newLeft)) {
list.style.left = parseInt(list.style.left) + speed + "px";
setTimeout(go, interval); // 递归
} else {
animated = false;
list.style.left = newLeft + "px";
if (newLeft > -1226) {
list.style.left = -8582 + "px";
}
if (newLeft < -8582) {
list.style.left = -1226 + "px";
}
}
}
go();
}