四虎精品视频-四虎精品成人免费网站-四虎黄色网-四虎国产视频-国产免费91-国产蜜臀97一区二区三区

用javascript來實現(xiàn)動畫導(dǎo)航效果的代碼

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

代碼

我們看到上面的圖片,想象下,它動起來是多么的優(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;            //小圖片個數(shù) 
    this.iImgHeight=75;        //小圖片高度 
    this.iOverSpeed=50;        //鼠標(biāo)經(jīng)過時候切換的時間 
    this.iOutSpeed=50;        //鼠標(biāo)離開時候切換的時間 
    this.eventObj=_7c;        //取得圖片對象      

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

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

GNB.prototype.menuMouseOver=function(){//鼠標(biāo)經(jīng)過 
    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)過圖片位置遞增 
    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)過圖片位置遞減 
    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(){//取消定時 
    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"));//實例單個按鈕,當(dāng)然也可以多個 
// ]]> 
</script>

演示地址

JavaScript技術(shù)用javascript來實現(xiàn)動畫導(dǎo)航效果的代碼,轉(zhuǎn)載需保留來源!

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

主站蜘蛛池模板: 中岛梓| 《隐秘而伟大》电视剧| 蓝莓之夜 电影| 西野翔电影| 舒羽| 网络胜利组| 疑云密布| 理发店电影| 风平浪静电影| 蒋锐| 电影《exotica》完整版观看| 蒋昌义| 恶搞之家拍脏片八季是哪一集| 小姐电影韩国| 木乃伊5| 黄色免费视频| av电影网| 王心凌照片| 小绵羊男星是谁| 《侏罗纪公园1》电影免费观看 | 金鸳鸯| 二年级上册音乐教案全册| 覃宏| 全球高考图片| 刀客家族| 从亘古到永远| 电影儿媳| 供货合同| 魔鬼黑狱1983年美国| 《欢·爱》郭晓东| 一个月经代表七个版本| 大内密探零零发演员表| 美少女写真| 场景歌评课| 女公安毛片免费观看| 中国黄色片子| 小学智力测试题100题| 冷血惊魂| 王梦婷| 继承者计划 电视剧| 恶行之外电影完整在线观看|