>
右滚>>button>
div>
varwarp=document.getElementById('warp');varcon=document.getElementById('con');varbox1=document.getElementById('box1');varbox2=document.getElementById('box2');varimg=box1.getElementsByTagName('img')[0];varscrollL=document.getElementById('scrollL');varscrollR=document.getElementById('scrollR');vartimer1=null,timer2=null,flage=1;
box2.innerHTML=box1.innerHTML;
max=box1.clientWidth;
imgmax=img.clientWidth+10;functionscrollLeft(){
flage=1;
clearInterval(timer1);
timer1=setInterval(function(){
warp.scrollLeft++;if(warp.scrollLeft>=max) {
warp.scrollLeft=0;
}if(warp.scrollLeft%imgmax==0){
clearInterval(timer1);
clearTimeout(timer2);
timer2=setTimeout(function(){
timer1=setInterval(scrollLeft,5)
},2000)
}
},5)
}functionscrollRight(){
flage=0;
clearInterval(timer1);
timer1=setInterval(function(){
warp.scrollLeft--;if(warp.scrollLeft<=0) {
warp.scrollLeft=max;
}if(warp.scrollLeft%imgmax==0){
clearInterval(timer1);
clearTimeout(timer2);
timer2=setTimeout(function(){
timer1=setInterval(scrollRight,5)
},2000)
}
},5)
}
scrollLeft();
scrollL.οnclick=function(){//clearInterval(timer1);
//clearTimeout(timer2);
scrollLeft();
}
scrollR.οnclick=function(){//clearInterval(timer1);
//clearTimeout(timer2);
scrollRight();
}
warp.οnmοuseenter=function(){
clearInterval(timer1);
clearTimeout(timer2);
}
warp.οnmοuseleave=function(){
clearInterval(timer1);
clearTimeout(timer2);
console.log(flage);if(flage) {scrollLeft();}else{scrollRight();}
}script>
body>
html>