UpDownRoller.prototype.uid=100;
function UpDownRoller(objID,selfName){
var obj=document.getElementById(objID);
obj.style.position="relative";
obj.style.zIndex=this.uid++;
this.target=obj;
this.autoRoll=false;
this.selfName=selfName;
this.timerID=null;
}
UpDownRoller.prototype.setAutoRoll=function(b){
if(this.autoRoll==b){
return null;
}
this.autoRoll=b;
if(b){
if(this.timerID){
window.clearInterval(this.timerID);
}
this.timerID=window.setInterval(this.selfName+".roll()",10);
}else{
this.target.style.pixelTop=0;
}
}
UpDownRoller.prototype.roll=function(){
if(!this.autoRoll){
return false;
}
var t=this.target;
t.style.pixelTop=document.body.scrollTop;
}
if(document.getElementById("floater")){
var ft=new UpDownRoller("floater","ft");
ft.setAutoRoll(true);
}
网页元素跟随BODY上下滚动JS组件
最新推荐文章于 2024-05-21 14:50:28 发布