轮播图
2017-10-10 本文已影响0人
向北_f098
鼠标进入停止
carousel.onmouseover = function(){
clearInterval(timer);
}
鼠标离开开始
~~~ carousel.onmouseout = function(){
timer = setInterval(rightBtnHandler,interval);
}~~~
按钮的监听
~~~rightBtn.onclick = rightBtnHandler;
function rightBtnHandler(){
if(lis[idx].isanimated) return;
animate(lis[idx],{"opacity" : 0},1000);
idx++;
if(idx > imgLength - 1){
idx = 0;
}
animate(lis[idx],{"opacity" : 1},1000);
changeCircle();
}~~~
小圆点的监听
~~~for(var i = 0 ; i <= imgLength - 1 ; i++){
circlesLi[i].index = i;
circlesLi[i].onclick = function(){
if(lis[idx].isanimated) return;
animate(lis[idx],{"opacity" : 0},1000);
idx = this.index;
animate(lis[idx],{"opacity" : 1},1000);
changeCircle();
}
}~~~
更换小圆点函数
~~~function changeCircle(){
for (var i = 0; i < circlesLi.length; i++) {
circlesLi[i].className = "";
}
circlesLi[idx].className = "cur";
}~~~