最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

JS實(shí)現(xiàn)Fisheye效果動感放大菜單代碼

 更新時間:2015年10月21日 09:46:13   作者:企鵝  
這篇文章主要介紹了JS實(shí)現(xiàn)Fisheye效果動感放大菜單代碼,涉及JavaScript事假監(jiān)聽機(jī)制及定時函數(shù)等相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下

本文實(shí)例講述了JS實(shí)現(xiàn)Fisheye效果動感放大菜單代碼。分享給大家供大家參考,具體如下:

這款Fisheye Menu,是采用JS+CSS+XHTML實(shí)現(xiàn)的動感放大菜單,放到圖標(biāo)上的時候,圖標(biāo)會被放大,整個菜單有緩沖彈簧的效果,學(xué)jQuery的朋友見的比較多,不過本款沒有用到j(luò)Query,效果卻同樣精彩。

運(yùn)行效果截圖如下:

在線演示地址如下:

http://demo.jb51.net/js/2015/js-fisheye-style-menu-demo/

具體代碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Fisheye 動感放大的菜單</title>
<style>
#fisheye_menu {
 list-style: none;
 padding: 0;
 margin: 10px;
 height: 81px;
}
#fisheye_menu li {
 position: relative;
 display: block;
 float: left;
}
#fisheye_menu span {
 position: absolute;
 top: 100%;
 left: 0;
 text-align: center;
 width: 79px;
 padding: 1px;
 margin: 0;
 border: solid 1px #bbb; 
 color: #333;
 background: #eee;
}
#fisheye_menu a {
 text-decoration: none;
}
#fisheye_menu img {
 border: 0;
 vertical-align: top;
}
</style>
<script type='text/javascript'>
var fisheyemenu = {
 startSize : 55,
 endSize : 88,
 imgType : ".gif",
 init : function () {
  var animElements = document.getElementById("fisheye_menu").getElementsByTagName("img");
  var titleElements = document.getElementById("fisheye_menu").getElementsByTagName("span");
  for(var j=0; j<titleElements.length; j++) {
   titleElements[j].style.display = 'none';
  }
  for(var i=0; i<animElements.length; i++) {
   var y = animElements[i];
   y.style.width = fisheyemenu.startSize+'px';
   y.style.height = fisheyemenu.startSize+'px';
   fisheyemenu.imgSmall(y);
   animElements[i].onmouseover = changeSize;
   animElements[i].onmouseout = restoreSize;
  }
  function changeSize() {
   fisheyemenu.imgLarge(this);
   var x = this.parentNode.getElementsByTagName("span");
   x[0].style.display = 'block';
   if (!this.currentWidth) this.currentWidth = fisheyemenu.startSize;
   fisheyemenu.resizeAnimation(this,this.currentWidth,fisheyemenu.endSize,15,10,0.333);
  }
  function restoreSize() {
   var x = this.parentNode.getElementsByTagName("span");
   x[0].style.display = 'none';
   if (!this.currentWidth) return;
   fisheyemenu.resizeAnimation(this,this.currentWidth,fisheyemenu.startSize,15,10,0.5);
   fisheyemenu.imgSmall(this);
  }
 },
 resizeAnimation : function (elem,startWidth,endWidth,steps,intervals,powr) {
  if (elem.widthChangeMemInt) window.clearInterval(elem.widthChangeMemInt);
  var actStep = 0;
  elem.widthChangeMemInt = window.setInterval(
   function() {
    elem.currentWidth = fisheyemenu.easeInOut(startWidth,endWidth,steps,actStep,powr);
    elem.style.width = elem.currentWidth+"px";
    elem.style.height = elem.currentWidth+"px";
    actStep++;
    if (actStep > steps) window.clearInterval(elem.widthChangeMemInt);
   }
   ,intervals)
 },
 easeInOut : function (minValue,maxValue,totalSteps,actualStep,powr) {
  var delta = maxValue - minValue;
  var stepp = minValue+(Math.pow(((1 / totalSteps)*actualStep),powr)*delta);
  return Math.ceil(stepp)
 },
 imgSmall : function (obj) {
  imgSrc = obj.getAttribute("src");
  var typePos = imgSrc.indexOf(fisheyemenu.imgType, 0);
  var imgName = imgSrc.substr(0, typePos);
  obj.setAttribute("src", imgName+"_small"+fisheyemenu.imgType);
 },
 imgLarge : function (obj) {
  imgSrc = obj.getAttribute("src");
  var typePos = imgSrc.indexOf("_small", 0);
  var imgName = imgSrc.substr(0, typePos);
  obj.setAttribute("src", imgName+fisheyemenu.imgType);
 }
}
if ( typeof window.addEventListener != "undefined" )
 window.addEventListener( "load", fisheyemenu.init, false );
else if ( typeof window.attachEvent != "undefined" )
 window.attachEvent( "onload", fisheyemenu.init );
else {
 if ( window.onload != null ) {
 var oldOnload = window.onload;
 window.onload = function ( e ) {
  oldOnload( e );
  fisheyemenu.init();
 };
 }
 else
 window.onload = fisheyemenu.init;
}
</script>
 </head>
 <body>
  <div>
   <ul id="fisheye_menu">
    <li><a href="#1"><img src="images/icon.gif" alt="腳本之家" /><span>Icon 1</span></a></li>
    <li><a href="#2"><img src="images/icon2.gif" alt="image description" /><span>Icon 2</span></a></li>
    <li><a href="#3"><img src="images/icon.gif" alt="腳本下載" /><span>Icon 3</span></a></li>
    <li><a href="#4"><img src="images/icon2.gif" alt="image description" /><span>Icon 4</span></a></li>
    <li><a href="#5"><img src="images/icon.gif" alt="jb51.net" /><span>Icon 5</span></a></li>
    <li><a href="#6"><img src="images/icon2.gif" alt="image description" /><span>Icon 6</span></a></li>
   </ul>
   </div>
 </body>
</html>

希望本文所述對大家JavaScript程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • UniApp使用manifest.json應(yīng)用配置的超詳細(xì)教學(xué)

    UniApp使用manifest.json應(yīng)用配置的超詳細(xì)教學(xué)

    這篇文章主要給大家介紹了關(guān)于uni-app應(yīng)用配置manifest.json最全最詳細(xì)配置,manifest.json文件是應(yīng)用的配置文件,用于指定應(yīng)用的名稱、圖標(biāo)、權(quán)限等,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2024-01-01
  • 優(yōu)化javascript的執(zhí)行效率一些方法總結(jié)

    優(yōu)化javascript的執(zhí)行效率一些方法總結(jié)

    本文為大家介紹下優(yōu)化javascript的執(zhí)行效率一些方法,個人感覺還不錯,感興趣的朋友可以了解下
    2013-12-12
  • JavaScript開發(fā)簡單易懂的Svelte實(shí)現(xiàn)原理詳解

    JavaScript開發(fā)簡單易懂的Svelte實(shí)現(xiàn)原理詳解

    這篇文章主要為大家介紹了JavaScript開發(fā)簡單易懂的Svelte實(shí)現(xiàn)原理的內(nèi)容詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步
    2021-11-11
  • JS、jquery實(shí)現(xiàn)幾分鐘前、幾小時前、幾天前等時間差顯示效果的代碼實(shí)例分享

    JS、jquery實(shí)現(xiàn)幾分鐘前、幾小時前、幾天前等時間差顯示效果的代碼實(shí)例分享

    在新浪微博首頁看到每條微博后邊顯示的時間并不是標(biāo)準(zhǔn)的年-月-日格式,而是經(jīng)過換算的時間差,如:發(fā)表于5分鐘前、發(fā)表于“2小時前”,比起標(biāo)準(zhǔn)的時間顯示格式,貌似更加直觀和人性化
    2014-04-04
  • C++中的string類的用法小結(jié)

    C++中的string類的用法小結(jié)

    通過在網(wǎng)站上的資料搜集,得到了很多關(guān)于string類用法的文檔,通過對這些資料的整理和加入一些自己的代碼,就得出了一份比較完整的關(guān)于string類函數(shù)有哪些和怎樣用的文檔了!
    2015-08-08
  • js讀取cookie方法總結(jié)

    js讀取cookie方法總結(jié)

    這篇文章主要介紹了js讀取cookie方法,實(shí)例總結(jié)了四種常用的讀取方法,包含了對cookie數(shù)據(jù)的分割與遍歷操作,是非常實(shí)用的技巧,需要的朋友可以參考下
    2014-10-10
  • js實(shí)現(xiàn)簡單的拖拽效果

    js實(shí)現(xiàn)簡單的拖拽效果

    這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)簡單的拖拽效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-09-09
  • Javascript 命名空間模式

    Javascript 命名空間模式

    命名空間是通過為項(xiàng)目或庫創(chuàng)建一個全局對象,然后將所有功能添加到該全局變量中。通過減少程序中全局變量的數(shù)量,實(shí)現(xiàn)單全局變量,從而在具有大量函數(shù)、對象和其他變量的情況下不會造成全局污染,同時也避免了命名沖突等問題
    2013-11-11
  • Echarts?graph關(guān)系圖的使用入門級教程

    Echarts?graph關(guān)系圖的使用入門級教程

    近期需要使用echarts關(guān)系圖,這里給大家總結(jié)下,這篇文章主要給大家介紹了關(guān)于Echarts?graph關(guān)系圖使用的相關(guān)資料,文中給出了詳細(xì)的代碼介紹,需要的朋友可以參考下
    2024-01-01
  • JS之獲取樣式的簡單實(shí)現(xiàn)方法(推薦)

    JS之獲取樣式的簡單實(shí)現(xiàn)方法(推薦)

    下面小編就為大家?guī)硪黄狫S之獲取樣式的簡單實(shí)現(xiàn)方法(推薦)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-09-09

最新評論

罗平县| 息烽县| 天水市| 诸城市| 巴彦淖尔市| 长寿区| 东阳市| 阜平县| 淄博市| 永胜县| 邢台市| 通城县| 吴忠市| 广灵县| 五台县| 枣庄市| 凤台县| 太湖县| 阳西县| 古丈县| 凤山县| 德庆县| 绥德县| 元朗区| 杂多县| 化德县| 娄烦县| 古浪县| 全州县| 平江县| 视频| 屏东市| 衡水市| 名山县| 利川市| 友谊县| 镇康县| 河曲县| 罗甸县| 临朐县| 海口市|