中文字幕日韩一区二区_国产一区二区av_国产毛片av_久久久久国产一区_色婷婷电影_国产一区二区精品

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

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

主站蜘蛛池模板: 99久久精品免费 | 亚洲国产日韩欧美 | 国产一区二区三区免费 | 狠狠狠色丁香婷婷综合久久五月 | 国产精品视频一区二区三区四区国 | 久久国产精品视频观看 | 精品国产91乱码一区二区三区 | 中文字幕一区二区三区日韩精品 | 亚洲一级二级三级 | 久久精品国产亚洲夜色av网站 | 久久久www成人免费精品 | 台湾佬久久 | 日韩av福利在线观看 | 日韩欧美专区 | 中文字幕精品一区 | 一级黄色片美国 | 亚洲欧美激情精品一区二区 | 欧美精品中文 | 精品1区2区| 婷婷丁香在线视频 | 一级毛片免费看 | 特级做a爱片免费69 精品国产鲁一鲁一区二区张丽 | 国产成人一区二区 | 亚洲精品9999久久久久 | 成人亚洲性情网站www在线观看 | 精品在线一区二区 | 国产色在线 | 日本一区二区三区四区 | 99热这里都是精品 | 色综合天天天天做夜夜夜夜做 | 亚洲精品一区二区 | 精品成人免费一区二区在线播放 | 国产片一区二区三区 | 夜夜干夜夜操 | 91成人精品 | 精品亚洲一区二区三区四区五区高 | 精品国产91久久久久久 | 成人国产在线视频 | 亚洲一区二区在线播放 | 91精品国产综合久久精品 | 亚洲欧美激情四射 |