日期:2014-05-16 浏览次数:20345 次
function adjust(containerID) {
var container = $("#" + containerID);
var imgs = container.find("img");
_self = this;
_self.speed = 3;
_self.imgs = imgs;
_self.container = container;
_self.width = parseInt(container.width());
_self.length = _self.imgs.length;
_self.imgWidth = Math.round(_self.width/_self.length);
_self.run = function () {
var left = Math.abs(parseInt(_self.container.css("left")));
if (left < _self.width - _self.imgWidth) {
_self.container.css("left", (-left - _self.speed) + "px");
console.log(left);
} else {
_self.container.find("img:eq(0)").appendTo(_self.container);
_self.container.css("left", (-left + _self.imgWidth - _self.speed) + "px");
}
setTimeout(function () {
_self.run();
}, 33);
}