手记

间歇性循环滚动(鼠标悬停)效果!

var area=document.getElementById('moocBox');
var iLiHeight=24;
area.innerHTML+=area.innerHTML;
area.scrollTop=0;
var speed=50;
var delay=2000;
var time;
var times;
function starMove(){
area.scrollTop++;
time=setInterval("scrollUp()",speed);
}
function scrollUp(){
//area.scrollTop++;
if(area.scrollTop%iLiHeight==0){
clearInterval(time);
times=setTimeout("starMove()",delay);
}else{
area.scrollTop++;
if(area.scrollTop>=area.scrollHeight/2){
area.scrollTop=0;
}
}
}
setTimeout("starMove()",delay); //初始化
area.onmouseover=function(){
clearInterval(time);
clearTimeout(times);
}
area.onmouseout=function(){
clearInterval(time);
clearTimeout(times);
time=setInterval("scrollUp()",speed);
}

0人推荐
随时随地看视频
慕课网APP