手记

关于无缝间歇性滚动的效果!!

function getDOM(id) {
       return document.getElementById(id);
   }
   var text=getDOM("moocBox");
   var con1=getDOM("con1");
   var con2=getDOM("con2");
   var timer;
   var times;
   con2.innerHTML=con1.innerHTML;
   function startMove() {
       text.scrollTop++;
       timer=setInterval("scrollUp()",50);
   }
   function scrollUp() {
       if(text.scrollTop % 24 ==0){
           clearInterval(timer);
           times=setTimeout("startMove()",2000);
       }else {
           text.scrollTop++;
           if(text.scrollTop==con1.offsetHeight){
               text.scrollTop=0;
           }
       }
   }
   startMove();
   text.onmouseover=function () {
       clearInterval(timer);
       clearTimeout(times);
   }
   text.onmouseout=function () {
       clearInterval(timer);
       clearTimeout(times);
       timer=setInterval("scrollUp()",50);
   }
3人推荐
随时随地看视频
慕课网APP