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

JS實現(xiàn)響應鼠標點擊動畫漸變彈出層效果代碼

 更新時間:2016年03月25日 11:21:50   作者:回不倒過去  
這篇文章主要介紹了JS實現(xiàn)響應鼠標點擊動畫漸變彈出層效果代碼,具有非常自然流暢的動畫過度效果,涉及JavaScript針對鼠標事件的響應及頁面元素樣式的動態(tài)操作相關(guān)技巧,需要的朋友可以參考下

本文實例講述了JS實現(xiàn)響應鼠標點擊動畫漸變彈出層效果。分享給大家供大家參考,具體如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>動畫彈出層</title>
<style>
.list{
 position:relative;;
 background:#eee;
 border:1px #ccc solid;
 margin:10px;
 height:30px;
 width:100px;
 cursor :pointer ;
}
.listShow{
 position:relative;
 background:#eff;
 border:1px #ddd solid;
 margin:10px;
 height:30px;
 width:100px;
 cursor :pointer ;
}
.comment{
 position:absolute;
 left:0;
 display:none;
 position:absolute;
 border:1px #ccc solid;
 background:#fee;
 width:200px;
 height:200px;
 overflow:hidden;
 z-index:100;
}
</style>
</head>
<body>
<div class="" id="show">
0
</div>
<div class="list" id="list1">1
 <div class="comment" id="comment1">腳本之家<br/>
</div>
<div class="list" id="list2">2
 <div class="comment" id="comment2">新浪搜狐</div>
</div>
<div class="list" id="list3">3
 <div class="comment" id="comment3">網(wǎng)頁特效</div>
</div>
</body>
</html>
<script>
 var zindex=0;
 function $id(id){
 return document.getElementById(id);
 }
 var Bind = function(object,fun){
 var args = Array.prototype.slice.call(arguments).slice(2);
 return function(){
  return fun.apply(object,args);
 }
 }
 function addEventHandler(oTarget, sEventType, fnHandler){
  if(oTarget.addEventListener){oTarget.addEventListener(sEventType, fnHandler, false);}
  else if(oTarget.attachEvent){oTarget.attachEvent('on' + sEventType, fnHandler);}
  else{oTarget['on' + sEventType] = fnHandler;}
 }
 var Shower=function(){
 this.list=null;
 this.comment=null;
 this.moveLeft=80;
 this.moveTop=20;
 this.height=150;
 this.width=250;
 this.time=800;
 this.init=function(lisObj,comObj){
  this.list=lisObj;
  this.comment=comObj;
  var _this=this;
  this._fnMove=Bind(this,this.move);
  (function(){
  var obj=_this;
  addEventHandler(obj.list,"click",obj._fnMove);
  })();
 };
 this.move=function(){
  var _this=this;
  var w=0;
  var h=0;
  var height=0; //彈出div的高
  var width=0; //彈出div的寬
  var t=0;
  var startTime = new Date().getTime();//開始執(zhí)行的時間
  if(!_this.comment.style.display||_this.comment.style.display=="none"){
   _this.comment.style.display="block";
   _this.comment.style.height=0+"px";
   _this.comment.style.width=0+"px";
   _this.list.style.zIndex=++zindex;
   _this.list.className="listShow";
   var comment=_this.comment.innerHTML;
   _this.comment.innerHTML=""; //去掉顯示內(nèi)容
   var timer=setInterval(function(){
   var newTime = new Date().getTime();
   var timestamp = newTime - startTime;
   _this.comment.style.left=Math.ceil(w)+"px";
   _this.comment.style.top=Math.ceil(h)+"px";
   _this.comment.style.height=height+"px";
   _this.comment.style.width=width+"px";
   t++;
  var change=(Math.pow((timestamp/_this.time-1), 3) +1); //根據(jù)運行時間得到基礎變化量
   w=_this.moveLeft*change;
   h=_this.moveTop*change;
   height=_this.height*change;
   width=_this.width*change;
   $id("show").innerHTML=w;
    if(w>_this.moveLeft){
clearInterval(timer);
_this.comment.style.left=_this.moveLeft+"px";
_this.comment.style.top=_this.moveTop+"px";
_this.comment.style.height=_this.height+"px";
_this.comment.style.width=_this.width+"px";
_this.comment.innerHTML=comment; //回復顯示內(nèi)容
}
},1,_this.comment);
  }else{
   _this.hidden();
  }
}
this.hidden=function(){
 var _this=this;
 var flag=1;
 var hiddenTimer=setInterval(function(){
 if(flag==1){
 _this.comment.style.height=parseInt(_this.comment.style.height)-10+"px";
 }else{    _this.comment.style.width=parseInt(_this.comment.style.width)-15+"px";
 _this.comment.style.left=parseInt(_this.comment.style.left)+5+"px";
 }
 if(flag==1 && parseInt(_this.comment.style.height)<10){
 flag=-flag;
 }
   if(parseInt(_this.comment.style.width)<20){
    clearInterval(hiddenTimer);
    _this.comment.style.left="0px";
    _this.comment.style.top="0px";
    _this.comment.style.height="0px";
    _this.comment.style.width="0px";
    _this.comment.style.display="none";
    if(_this.list.style.zIndex==zindex){
    zindex--;
    };
    _this.list.style.zIndex=0;
    _this.list.className="list";
   }
  },1)
 }
 }
 window.onload=function(){
 //建立各個菜單對象
 var shower1=new Shower();
 shower1.init($id("list1"),$id("comment1"));
 var shower2=new Shower();
 shower2.init($id("list2"),$id("comment2"));
 var shower3=new Shower();
 shower3.init($id("list3"),$id("comment3"));
 }
</script>

更多關(guān)于JavaScript相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《JavaScript查找算法技巧總結(jié)》、《JavaScript動畫特效與技巧匯總》、《JavaScript錯誤與調(diào)試技巧總結(jié)》、《JavaScript數(shù)據(jù)結(jié)構(gòu)與算法技巧總結(jié)》、《JavaScript遍歷算法與技巧總結(jié)》及《JavaScript數(shù)學運算用法總結(jié)

希望本文所述對大家JavaScript程序設計有所幫助。

相關(guān)文章

  • JS實現(xiàn)的碰撞檢測與周期移動完整示例

    JS實現(xiàn)的碰撞檢測與周期移動完整示例

    這篇文章主要介紹了JS實現(xiàn)的碰撞檢測與周期移動,結(jié)合完整實例形式分析了javascript結(jié)合時間函數(shù)的頁面元素屬性動態(tài)操作及事件響應相關(guān)使用技巧,需要的朋友可以參考下
    2019-09-09
  • JS代碼實現(xiàn)根據(jù)時間變換頁面背景效果

    JS代碼實現(xiàn)根據(jù)時間變換頁面背景效果

    這篇文章主要介紹了JS代碼實現(xiàn)根據(jù)時間變換頁面背景效果的相關(guān)資料,非常不錯,具有參考借鑒價值,需要的朋友一起看下吧
    2016-06-06
  • javascript實現(xiàn)點擊按鈕切換圖片

    javascript實現(xiàn)點擊按鈕切換圖片

    這篇文章主要為大家詳細介紹了javascript實現(xiàn)點擊按鈕切換圖片,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-08-08
  • jsp 自動編譯機制詳細介紹

    jsp 自動編譯機制詳細介紹

    這篇文章主要介紹了 Jasper的自動檢測實現(xiàn)的機制比較簡單,依靠某后臺線程不斷檢測JSP文件與編譯后的class文件的最后修改時間是否相同,若相同則認為沒有改動,但倘若不同則需要重新編譯,需要的朋友可以參考下
    2016-12-12
  • JS判斷iframe是否加載完成的方法

    JS判斷iframe是否加載完成的方法

    這篇文章主要介紹了JS判斷iframe是否加載完成的方法,提供了2種實現(xiàn)方法,可分別針對IE內(nèi)核與非IE內(nèi)核瀏覽器進行判斷與操作,涉及javascript事件操作與判定技巧,需要的朋友可以參考下
    2016-08-08
  • javascript中scrollTop詳解

    javascript中scrollTop詳解

    本文主要給大家介紹了javascript中的scrollTop方法,以及scrollTop在各大瀏覽器的兼容性情況的詳細測試,十分的細致全面,這里推薦給大家,有需要的小伙伴可以參考下。
    2015-04-04
  • 微信小程序?qū)崿F(xiàn)菜單左右聯(lián)動效果

    微信小程序?qū)崿F(xiàn)菜單左右聯(lián)動效果

    這篇文章主要為大家詳細介紹了微信小程序?qū)崿F(xiàn)菜單左右聯(lián)動效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-07-07
  • js面向?qū)ο缶幊讨绾螌崿F(xiàn)方法重載

    js面向?qū)ο缶幊讨绾螌崿F(xiàn)方法重載

    如何實現(xiàn)方法重載,涉及到三個問題:同名函數(shù)的調(diào)用、函數(shù)中特殊的參數(shù)arguments、如何利用arguments實現(xiàn)方法重載,需要的朋友可以參考下
    2014-07-07
  • JS+CSS實現(xiàn)DIV層的展開、收縮效果

    JS+CSS實現(xiàn)DIV層的展開、收縮效果

    這篇文章主要介紹了JS+CSS實現(xiàn)DIV層的展開、收縮效果,以兩個完整實例介紹了JS控制DIV層的展開、收縮效果,感興趣的小伙伴們可以參考一下
    2016-01-01
  • JS簡單判斷字符在另一個字符串中出現(xiàn)次數(shù)的2種常用方法

    JS簡單判斷字符在另一個字符串中出現(xiàn)次數(shù)的2種常用方法

    這篇文章主要介紹了JS簡單判斷字符在另一個字符串中出現(xiàn)次數(shù)的2種常用方法,結(jié)合實例形式分析了js字符串分割計算與正則操作2種實現(xiàn)技巧,需要的朋友可以參考下
    2017-04-04

最新評論