天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

JS動(dòng)畫效果代碼3

慢慢來,這次實(shí)現(xiàn)了向任意方向擴(kuò)展!
復(fù)制代碼 代碼如下:
<!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>Untitled Document</title> 
<style type="text/css"> 
<!-- 
#apDiv1 { 
 position:absolute; 
 left:300px; 
 top:100px; 
 width:100px; 
 height:100px; 
 z-index:1; 
 background-color: #FF00FF; 

#apDiv2 { 
 position:absolute; 
 left:402px; 
 top:100px; 
 width:100px; 
 height:100px; 
 z-index:2; 
 background-color: #00FFFF; 

#apDiv3 { 
 position:absolute; 
 left:402px; 
 top:200px; 
 width:100px; 
 height:100px; 
 z-index:3; 
 background-color: #99FF00; 

#apDiv4 { 
 position:absolute; 
 left:300px; 
 top:200px; 
 width:100px; 
 height:100px; 
 z-index:4; 
 background-color: #FFFF00; 

--> 
</style> 
</head> 

<body> 
    <div id="apDiv1"></div> 
    <div id="apDiv2"></div> 
<div id="apDiv3"></div> 
<div id="apDiv4"></div> 
</body> 
</html> 
<script language="Javascript" type="text/Javascript"> 
function $(pId){ 
 return document.getElementById(pId); 


function JPos(){ 



JPos.getAbsPos = function(pTarget){ 
 var _x = 0; 
 var _y = 0; 
 while(pTarget.offsetParent){ 
   _x += pTarget.offsetLeft; 
   _y += pTarget.offsetTop; 
   pTarget = pTarget.offsetParent; 
 } 
 _x += pTarget.offsetLeft; 
 _y += pTarget.offsetTop; 

 return {x:_x,y:_y}; 


function JAniObj(){ 
 this.obj = null; 
 this.interval = null; 

 this.orgPos = null; 
 this.targetPos = null; 

 this.orgSize = {w:50,y:50};  //初始長(zhǎng)寬 
 this.targetSize = {w:100,y:100}; //目標(biāo)長(zhǎng)寬 
 this.step  = {x:10,y:10};  //步長(zhǎng) x:x方向 y:y方向 
 this.alpha  = {s:10,e:90,t:10};  //透明度,s初始,e結(jié)束,t步長(zhǎng) 


function JAni(){ 
 var self = this; 
 var aniObjs = {}; 

 var getCurrentStyleProperty = function(pObj,pProperty){ 
  try{  
   if(pObj.currentStyle) 
    return eval("pObj.currentStyle." + pProperty); 
   else 
    return document.defaultView.getComputedStyle(pObj,"").getPropertyValue(pProperty); 
  }catch(e){ 
   alert(e); 
  } 
 } 

 this.popup = function(pDiv,pOrgSize,pTargetSize,pStep,pAlpha){ 

  var aniObj = new JAniObj(); 
  aniObjs[pDiv] = aniObj; 

  with(aniObj){ 
   obj   = $(pDiv); 
   orgPos  = JPos.getAbsPos(obj); 
   orgSize  = pOrgSize; 
   targetSize = pTargetSize; 
   step  = pStep; 
   alpha  = pAlpha; 

   with(obj.style){ 
    overflow = "hidden"; 
    position = "absolute"; 
    width = pOrgSize.w + "px"; 
    height = pOrgSize.h + "px"; 
    left = orgPos.x + "px"; 
    top = orgPos.y + "px";  
    if(document.all){ 
     filter = "Alpha(opacity=" + pAlpha.s + ")"; 
    }else 
     opacity = pAlpha.s / 100; 
   }    
  } 

  aniObj.interval = setInterval("popup_('" + pDiv + "')",10); 
 } 

 popup_ = function(pDivId){ 

   
  pObj = aniObjs[pDivId]; 

  var w = parseInt(pObj.obj.style.width); 
  var h = parseInt(pObj.obj.style.height); 

  if(w >= Math.abs(pObj.targetSize.w) && h >= Math.abs(pObj.targetSize.h)){ 
   clearInterval(pObj.interval); 
   if(document.all) 
    pObj.obj.style.filter = "Alpha(opacity=" + pObj.alpha.e + ")"; 
   else 
    pObj.obj.style.opacity = pObj.alpha.e / 100; 

    

   delete aniObjs[pObj.obj.id]; 
  }else{ 
   if(w < Math.abs(pObj.targetSize.w)) 
    w += pObj.step.x; 

   if(h < Math.abs(pObj.targetSize.h)) 
    h += pObj.step.y; 

   if(document.all){ 
    var pattern = /opacity=(/d{1,3})/; 
    var result = pattern.exec(pObj.obj.style.filter); 
    if(result != null){ 
     if(result[1] < pObj.alpha.e) 
      pObj.obj.style.filter = "Alpha(opacity=" + (result[1] + pObj.alpha.t) + ")" 
     else 
      pObj.obj.style.filter = "Alpha(opacity=" + pObj.alpha.e + ")"; 
    } 
   }else{ 
    if(pObj.obj.style.opacity < pObj.alpha.e / 100){ 
     pObj.obj.style.opacity = parseFloat(pObj.obj.style.opacity) + pObj.alpha.t / 100; 
    }else 
     pObj.obj.style.opacity = pObj.alpha.e / 100; 
   } 
  } 

  pObj.obj.style.width = w + "px"; 
  pObj.obj.style.height = h + "px"; 

  if(pObj.targetSize.w < 0){ 
   var vLeft = parseInt(getCurrentStyleProperty(pObj.obj,"left")); 
   vLeft = isNaN(vLeft) ? 0 : vLeft; 
   pObj.obj.style.left = vLeft - pObj.step.x + "px"; 
  } 

  if(pObj.targetSize.h < 0){ 
   var vTop = parseInt(getCurrentStyleProperty(pObj.obj,"top")); 
   vTop = isNaN(vTop) ? 0 : vTop; 
   pObj.obj.style.top = vTop - pObj.step.y + "px"; 
  }   
 } 


var ani = new JAni(); 
 ani.popup( 
    "apDiv1", 
    {w:50,h:50}, //初始長(zhǎng)寬 
    {w:200,h:200}, //目標(biāo)長(zhǎng)寬 
    {x:8,y:8},  //步長(zhǎng) 
    {s:10,e:80,t:10}//透明度 起始,結(jié)束,步長(zhǎng) 
    ); 

 ani.popup( 
    "apDiv2", 
    {w:50,h:50}, //初始長(zhǎng)寬 
    {w:-200,h:200}, //目標(biāo)長(zhǎng)寬 
    {x:8,y:8},  //步長(zhǎng) 
    {s:10,e:40,t:2}//透明度 起始,結(jié)束,步長(zhǎng) 
    ); 

 ani.popup( 
    "apDiv3", 
    {w:50,h:50}, //初始長(zhǎng)寬 
    {w:-200,h:-200},//目標(biāo)長(zhǎng)寬 
    {x:8,y:8},  //步長(zhǎng) 
    {s:10,e:40,t:10}//透明度 起始,結(jié)束,步長(zhǎng) 
    ); 

 ani.popup( 
    "apDiv4", 
    {w:50,h:50}, //初始長(zhǎng)寬 
    {w:200,h:-200},//目標(biāo)長(zhǎng)寬 
    {x:8,y:8},  //步長(zhǎng) 
    {s:10,e:50,t:10}//透明度 起始,結(jié)束,步長(zhǎng) 
    );   
</script> 

JavaScript技術(shù)JS動(dòng)畫效果代碼3,轉(zhuǎn)載需保留來源!

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

主站蜘蛛池模板: 欧美精品3atv一区二区三区 | av天堂电影网 | 两个人看的www免费高清直播 | 人妻中文字幕乱人伦在线 | 全部免费特黄特色大片看片 | 伊人亚洲综合青草青草久热 | 欧美成a人片免费看久久 | 少妇精品久久久一区二区三区 | 亚洲精品国产专区91在线 | SM高H黄暴NP辣H调教性奴 | 亚洲国产日韩欧美在线a乱码 | 亚州综合网 | 又黄又爽又无遮挡在线观看免费 | 男插女高潮一区二区 | 精品久久久亚洲精品中文字幕 | 做暖免费观看日本 | 亚洲AV无码乱码在线观看浪潮 | 国产亚洲精品久久久久久久 | 久久re这里精品23 | 中文字幕在线免费观看视频 | 亚洲伊人色综合久久天天伊人 | 国产午夜三区视频在线 | 亚洲欧美一区二区三区四区 | 成年AV动漫| 久久久国产精品免费A片蜜臀 | 99精品国产在热 | 俄罗斯破处 | 国产精品久久人妻互换毛片 | 天天影视香色欲综合网 | 国产在线播放91 | 亚洲天堂av2017| 高中生被C到爽哭视频免费 高挑人妻无奈张开腿 | 国产亚洲日韩欧美视频 | 国产美女影院 | 亚洲精品久久YY5099 | 亚洲国产AV一区二区三区四区 | 伊人最新网址 | 边摸边吃奶边做激情叫床视 | 国产精品久久人妻拍拍水牛影视 | 久久久久999 | 国内高清在线观看视频 |