一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

javascript AutoScroller 函數類

復制代碼 代碼如下:
/*
* Copyright (C) 2007-2009 skylark
* Email:aohailin@gmail.com
* Version:2.1
* 原創程序,轉載請保留版權
*/
var $=function(o){return typeof o=="string"?document.getElementById(o):o;};
function AutoScroll(){
this.obj=[];
this.version="2.1";
this.Build();//初始化
};
AutoScroll.prototype.Build=function(){
var me=this;
//取得其他滾動事件
var oldscroll=window.onscroll;
window.onscroll=function(){
//保護其他滾動事件
if("function"==typeof oldscroll){
oldscroll();
}
//得到客戶端瀏覽器參數,兼容IE,FF,Chrome
this.common={
t:document.documentElement.scrollTop||document.body.scrollTop,
h:document.documentElement.clientHeight||document.body.clientHeight,
w:document.documentElement.clientWidth||document.body.clientWidth
};
this.position=[];
for(var i=0;i<me.obj.length;i++){
try{
this.style={};
//獲得客戶端位置,設置了7種位置
//為了讓最小化自動適應位置,這里動態計算位置,所以滾動事件觸發時,CPU消耗很大
this.position[i]=[
{x:0,y:this.common.t},
{x:this.common.w-me.obj[i].obj.offsetWidth,y:this.common.t},
{x:0,y:(this.common.h+this.common.t-me.obj[i].obj.offsetHeight)/2+(this.common.t)/2},
{x:this.common.w-me.obj[i].obj.offsetWidth,y:(this.common.h+this.common.t-me.obj[i].obj.offsetHeight)/2+(this.common.t)/2},
{x:(this.common.w-me.obj[i].obj.offsetWidth)/2,y:(this.common.h+this.common.t-me.obj[i].obj.offsetHeight)/2+(this.common.t)/2},
{x:0,y:this.common.h+this.common.t-me.obj[i].obj.offsetHeight},
{x:this.common.w-me.obj[i].obj.offsetWidth,y:this.common.h+this.common.t-me.obj[i].obj.offsetHeight}
];
//處理自定義樣式
this.style="object"==typeof me.obj[i].style?{x:me.obj[i].style.left,y:me.obj[i].style.top+this.common.t}:{x:this.position[i][me.obj[i].style].x,y:this.position[i][me.obj[i].style].y};
//定位
me.obj[i].obj.style.left=this.style.x+"px";
me.obj[i].obj.style.top=this.style.y+"px";
}catch(e){
//功能是過濾無效obj
for(var j=i;j<me.obj.length-1;j++){
me.obj[j]=me.obj[j+1];
me.obj.length=me.obj.length-1;
}
}
}
};
//初始化
window.scroll(1,1);
};
AutoScroll.prototype.Add=function(){
var obj=arguments[0];
//獲得當前position
var oldposition=$(obj.id).style.position;
$(obj.id).style.position="absolute";
//不使用fixed,雖然高版本瀏覽器都已經支持fixed
this.obj.push({
obj:$(obj.id),
oldposition:oldposition,
style:obj.style
});
};
AutoScroll.prototype.Remove=function(){
var obj=arguments[0];
for(var i=0;i<this.obj.length;i++){
if(this.obj[i].obj==$(obj.id)){
//還原初始狀態position
this.obj[i].obj.style.position=this.obj[i].oldposition;
//是否真正移除
if(obj.remove){
this.obj[i].obj.innerHTML="";
document.body.removeChild(this.obj[i].obj);
}
//移除obj
for(var j=i;j<this.obj.length-1;j++){
this.obj[j]=this.obj[j+1];
}
this.obj.length=this.obj.length-1;
break;
}
}
};
var Scroller=new AutoScroll();

JavaScript技術javascript AutoScroller 函數類,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 男女性色大片免费网站 | 婷婷色中文网 | 91成人午夜精品福利院在线观看 | 九一色视频 | 国产香蕉成人综合精品视频 | 国产成人综合亚洲欧洲色就色 | 欧洲大胆人体 | 色网站综合| 黄色在线视频播放 | 亚洲免费视频一区二区三区 | 国内精品国语自产拍在线观看91 | 黄色网址中文字幕 | 精品国产欧美精品v | 亚洲欧美成人综合久久久 | 久久免费视频6 | 91精品国产自产在线观看高清 | 亚洲精品人成无码中文毛片 | 亚洲91在线 | 91精品国产福利尤物 | 婷婷的五月 | 久久精品视频91 | 伊人久久综合网亚洲 | 国产成人涩涩涩视频在线观看 | 国产精品午夜国产小视频 | 国产免费91 | 亚洲一区二区中文 | 在线久| 六月婷婷开开放处 | 怡红院官网 | 亚洲天堂美女视频 | 久久久久国产一级毛片高清片 | 欧美黑人巨大xxxxxxxx | 青青草国产免费国产 | 日韩中文字幕在线有码视频网 | 久久精品国产一区二区三区肥胖 | 色黄视频在线观看 | 97国产精品人人爽人人做 | 亚洲一区二区三区四区视频 | 青青自拍视频一区二区三区 | 91刘亦菲精品福利在线 | 日韩中文字幕精品久久 |