function AutoPlay(){
this.imgList = document.getElementById("img-list");
this.banner = document.getElementById("banner");
this.arr = document.getElementById("arr");
this.toLeft = document.getElementById("toLeft");
this.toRight = document.getElementById("toRight");
this.navList = document.getElementById("banner-nav-list");
this.navLi = this.navList.children;
this.imgLi = this.imgList.children;
this.index = 0;
this.timer = null;
}
AutoPlay.prototype.init = function(){
this.auto();
this.bannerOver();
this.bannerOut();
this.leftClick();
this.rightClick();
}
AutoPlay.prototype.auto = function(){
/* this.timer = setInterval(function(){
if(this.index === this.imgLi.length-1){
this.imgList.style.left = 0;
this.index = 1;
}else{
this.index++;
}
console.log(this.index)
var j = this.index === this.imgLi.length-1 ? 0 : this.index;
this.potoMove(j); e th uk.'' = "active";
}.bind(this),1000); */
// this.timer = setInterval(this.indexChange,1000);//直接将indexChange方法作为回调,方法内部this是window
this.timer = setInterval(this.indexChange.bind(this),1000);
return this;
}
AutoPlay.prototype.indexChange =
js用构造函数实现轮播图效果
最新推荐文章于 2023-03-06 10:31:30 发布