一区二区久久-一区二区三区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 函數類,轉載需保留來源!

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

主站蜘蛛池模板: 国产成人亚洲精品2020 | 日本a级精品一区二区三区 日本a在线看 | 一本久道久久综合 | 亚洲国产天堂久久综合图区 | 九九色视频| 91在线播放视频 | 亚洲视频三区 | 91中文字幕在线一区 | 天堂色区| 欧美视频在线观看免费播放 | 91福利影院 | 青青自拍视频一区二区三区 | 久久久久久亚洲精品不卡 | 国产一级毛片午夜福 | 亚洲午夜精品aaa级久久久久 | 极品丝袜高跟91极品系列 | 久久不卡一区二区三区 | 精品日韩二区三区精品视频 | 免费播放欧美一级特黄 | 美女扒开双腿让男人爽透视频 | 夜夜操伊人 | 97麻豆精品国产自产在线观看 | 欧洲精品在线视频 | 成人爽a毛片在线视频 | 日韩亚洲欧洲在线com91tv | 久久亚洲人成网站 | 成人在线91| 亚洲高清中文字幕一区二区三区 | 狠狠做深爱婷婷久久一区 | 欧美人与禽zoz0性伦交免费看 | 在线视频天堂 | 国产91精品久久久久999 | 激情影院免费看 | 开心久久激情 | 李雅在线观看一区国产 | 中文字幕专区在线亚洲 | 亚洲国产精品久久久久网站 | 国产一区二区三区在线看 | 91精品国产闺蜜国产在线 | 国产精品久久九九 | 全黄三级 |