中文字幕日韩一区二区_国产一区二区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 函數類,轉載需保留來源!

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

主站蜘蛛池模板: 人妖一区| 天天爽天天操 | 国产一二区免费视频 | 国产偷录叫床高潮录音 | 日韩一区中文字幕 | 欧美乱人伦视频 | 日本不卡一区二区三区 | 欧美自拍第一页 | 在线观看视频一区 | 久草在线中文888 | 亚洲国产成人在线视频 | www.黄色片视频 | 亚洲另类视频 | 亚洲久久久| www.亚洲一区二区三区 | 一区免费 | 黄色网址免费在线观看 | 国产精品国产成人国产三级 | 久久综合影院 | 黄网站免费入口 | 国产福利在线播放麻豆 | 一级a性色生活片久久毛片波多野 | 久久久久久国 | 国产精品一区一区三区 | 亚洲一区精品在线 | 午夜视频一区 | 自拍偷拍亚洲一区 | 久久久久成人精品免费播放动漫 | 久久aⅴ乱码一区二区三区 亚洲欧美综合精品另类天天更新 | 鲁视频| 欧美日韩综合一区 | 狠狠狠干| 色综合久久久 | 中文字幕在线一区二区三区 | a级黄色片在线观看 | 亚洲免费一区二区 | 欧美综合一区 | www.亚洲| 成人精品视频 | 久久伊人在 | 中文字幕在线一区二区三区 |