var oldpage = 0;
var nowpage = 0;
var hometimer;
libtns[0].classList.add("curclick");
function homeWheel(){
for(var i =0;i<libtns.length;i++){//手动切换
libtns[i].index = i;
libtns[i].onclick = function(){
if(oldpage != this.index){
console.log(this.index);
for(var j = 0;j<libtns.length;j++){
libtns[j].classList.remove("curclick");
}
this.classList.add("curclick");
if(oldpage<this.index){
libgs[this.index].classList.remove("leftdown");
libgs[this.index].classList.remove("leftshow");
libgs[this.index].classList.remove("rightdown");
libgs[this.index].classList.add("rightshow");
libgs[oldpage].classList.remove("rightshow");
libgs[oldpage].classList.remove("leftshow");
libgs[oldpage].classList.remove("rightdown");
libgs[oldpage].classList.add("leftdown");
}
if(oldpage>this.index){
libgs[this.index].classList.remove("leftdown");
libgs[this.index].classList.remove("rightshow");
libgs[this.index].classList.remove("rightdown");
libgs[this.index].classList.add("leftshow");
libgs[oldpage].classList.remove("rightshow");
libgs[oldpage].classList.remove("leftshow");
libgs[oldpage].classList.remove("leftdown");
libgs[oldpage].classList.add("rightdown");
}
oldpage = this.index;
}
}
}
wheelrun();
function wheelrun(){//自动切换
hometimer = setInterval(function(){
nowpage = oldpage+1;
if(oldpage==libtns.length-1){
nowpage = 0;
}
for(var j = 0;j<libtns.length;j++){
libtns[j].classList.remove("curclick");
}
libtns[nowpage].classList.add("curclick");
if(oldpage<nowpage){
libgs[nowpage].classList.remove("leftdown");
libgs[nowpage].classList.remove("leftshow");
libgs[nowpage].classList.remove("rightdown");
libgs[nowpage].classList.add("rightshow");
libgs[oldpage].classList.remove("rightshow");
libgs[oldpage].classList.remove("leftshow");
libgs[oldpage].classList.remove("rightdown");
libgs[oldpage].classList.add("leftdown");
}
if(oldpage>nowpage){
libgs[nowpage].classList.remove("leftdown");
libgs[nowpage].classList.remove("rightshow");
libgs[nowpage].classList.remove("rightdown");
libgs[nowpage].classList.add("leftshow");
libgs[oldpage].classList.remove("rightshow");
libgs[oldpage].classList.remove("leftshow");
libgs[oldpage].classList.remove("leftdown");
libgs[oldpage].classList.add("rightdown");
}
oldpage = nowpage;
},3000);
}
play1.onmouseenter = function(){//鼠标移入至目标区域则停止自动切换
clearInterval(hometimer);
}
play1.onmouseleave = function(){//鼠标移出至目标区域则开始自动切换
wheelrun();
}
}