欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

用javascript來(lái)實(shí)現(xiàn)動(dòng)畫導(dǎo)航效果的代碼

 更新時(shí)間:2007年12月16日 21:31:02   投稿:mdxy-dxy  
javascript來(lái)實(shí)現(xiàn)動(dòng)畫導(dǎo)航效果是通過(guò)定時(shí)器與鼠標(biāo)事件響應(yīng)相結(jié)合,動(dòng)態(tài)修改頁(yè)面元素屬性實(shí)現(xiàn)的動(dòng)畫導(dǎo)航效果,需要的朋友可以參考一下

誰(shuí)在用這些導(dǎo)航
google是個(gè)大公司,全世界都有g(shù)oogle的腳印,韓國(guó)的google動(dòng)畫效果非常不錯(cuò),藍(lán)色理想論壇里已經(jīng)有人挖過(guò)來(lái)了,可惜js寫的太多了,那自己寫一個(gè)吧?好,就這么干!
原理
小時(shí)候,總喜歡看動(dòng)畫片吧,動(dòng)畫片是怎樣實(shí)現(xiàn)的呢?記得媽媽說(shuō)是一張畫一張畫切換過(guò)去(啊?那一部葫蘆兄弟要畫多少副畫啊? -_-! ),其實(shí)我們現(xiàn)在做的也是這樣,用一個(gè)圖片,這個(gè)圖片里有很多個(gè)小圖,來(lái)顯示動(dòng)畫軌跡.按時(shí)間來(lái)移動(dòng)圖片,那圖片不是會(huì)動(dòng)了啊?(不知道,表達(dá)清楚了沒…語(yǔ)文很重要啊!!)
準(zhǔn)備
我們需要一張圖片,一個(gè)大腦,一張會(huì)笑的臉(不笑效果就出不來(lái)了….)!!下面是我準(zhǔn)備的圖片(ps水平有限^_^)…

代碼

我們看到上面的圖片,想象下,它動(dòng)起來(lái)是多么的優(yōu)美啊…

css

復(fù)制代碼 代碼如下:


.Gnb_btn_div{ 
    width:90px; 
    height:75px; 
    overflow:hidden; 
    display:block; 
    position:absolute; 
}      

.Gnb_btn_img{ 
    width:100%; 
    height:525px; 
    display:block; 
    overflow:hidden; 
    text-indent:-500px; 

#gnb_btn_01 .Gnb_btn_img { 
    background-image:url(http://www.wler.cn/blog/img/friend.gif) 
}

javascript

復(fù)制代碼 代碼如下:

<script type="text/javascript"> 
// <![CDATA[ 
function GNB(_7c){ 
    //初始化一些參數(shù) 
    this.iImgNum=7;            //小圖片個(gè)數(shù) 
    this.iImgHeight=75;        //小圖片高度 
    this.iOverSpeed=50;        //鼠標(biāo)經(jīng)過(guò)時(shí)候切換的時(shí)間 
    this.iOutSpeed=50;        //鼠標(biāo)離開時(shí)候切換的時(shí)間 
    this.eventObj=_7c;        //取得圖片對(duì)象      

    this.MouseOverFlag=false; 
    this.imageIndex=0; 
    if(this.eventObj==null){return;} 
    this.eventObj.parentClass=this;this.eventAssign(); 
}      

GNB.prototype.eventAssign=function(){//注冊(cè)事件 
    this.eventObj.onmouseover=this.menuMouseOver; 
    this.eventObj.onmouseout=this.menuMouseOut; 
};      

GNB.prototype.menuMouseOver=function(){//鼠標(biāo)經(jīng)過(guò) 
    if(this.parentClass.MouseOverFlag!=false){return;} 
    this.parentClass.MouseOverFlag=true; 
    this.parentClass.clearTimeOut(); 
    this.parentClass.menuMouseOverTimer(); 
};      

GNB.prototype.menuMouseOut=function(){//鼠標(biāo)離開 
    this.parentClass.MouseOverFlag=false; 
    this.parentClass.clearTimeOut(); 
    this.parentClass.menuMouseOutTimer(); 
};      

GNB.prototype.menuMouseOverTimer=function(){//經(jīng)過(guò)圖片位置遞增 
    var _7d=this; 
    if(this.imageIndex>=this.iImgNum){return;} 
    this.eventObj.scrollTop=this.imageIndex*this.iImgHeight; 
    this.imageIndex++; 
    this.setTimerID=setTimeout(function(){_7d.menuMouseOverTimer();},this.iOverSpeed); 
};      

GNB.prototype.menuMouseOutTimer=function(){////經(jīng)過(guò)圖片位置遞減 
    var _7e=this;if(this.imageIndex<0){return;} 
    this.eventObj.scrollTop=this.imageIndex*this.iImgHeight; 
    this.imageIndex--; 
    this.setTimerID=setTimeout(function(){_7e.menuMouseOutTimer();},this.iOutSpeed); 
};      

GNB.prototype.clearTimeOut=function(){//取消定時(shí) 
    clearTimeout(this.setTimerID); 
}; 
// ]]> 
</script>

xhtml
復(fù)制代碼 代碼如下:


<div class="Gnb_btn_div" id="gnb_btn_01"> 
<a class="Gnb_btn_img" href="#1" href="#1">找朋友</a> 
</div>      

<script type="text/javascript"> 
// <![CDATA[ 
var GNB1=new GNB(document.getElementById("gnb_btn_01"));//實(shí)例單個(gè)按鈕,當(dāng)然也可以多個(gè) 
// ]]> 
</script>

演示地址

相關(guān)文章

最新評(píng)論