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

JS動畫效果代碼3

 更新時間:2008年04月03日 19:37:12   作者:  
用js實(shí)現(xiàn)的動畫效果
慢慢來,這次實(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};  //初始長寬 
 this.targetSize = {w:100,y:100}; //目標(biāo)長寬 
 this.step  = {x:10,y:10};  //步長 x:x方向 y:y方向 
 this.alpha  = {s:10,e:90,t:10};  //透明度,s初始,e結(jié)束,t步長 


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}, //初始長寬 
    {w:200,h:200}, //目標(biāo)長寬 
    {x:8,y:8},  //步長 
    {s:10,e:80,t:10}//透明度 起始,結(jié)束,步長 
    ); 

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

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

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

相關(guān)文章

  • JavaScript 精粹讀書筆記(1,2)

    JavaScript 精粹讀書筆記(1,2)

    JavaScript的特性中有一部分特性帶來的麻煩遠(yuǎn)遠(yuǎn)超出它們的價值。
    2010-02-02
  • javascript iframe中打開文件,并檢測iframe存在否

    javascript iframe中打開文件,并檢測iframe存在否

    從iframe中打開文件,并檢測iframe存在否如果說只是檢測頁面存在否,直接設(shè)置target用偽協(xié)議就可以解決了...
    2008-12-12
  • JS中setTimeout()的用法詳解

    JS中setTimeout()的用法詳解

    setTimeout( ) 是屬于 window 的 method, 但我們都是略去 window 這頂層物件名稱, 這是用來設(shè)定一個時間, 時間到了, 就會執(zhí)行一個指定的 method
    2013-04-04
  • JSONP基礎(chǔ)知識詳解

    JSONP基礎(chǔ)知識詳解

    JSONP是JSON with padding(填充式JSON或參數(shù)式JSON)的簡寫,是應(yīng)用JSON的一種新方法,常用于務(wù)器與客戶端跨源通信,在后來的Web服務(wù)中非常流行。本文將詳細(xì)介紹JSONP,下面跟著小編一起來看下吧
    2017-03-03
  • headjs實(shí)現(xiàn)網(wǎng)站并行加載但順序執(zhí)行JS

    headjs實(shí)現(xiàn)網(wǎng)站并行加載但順序執(zhí)行JS

    本文主要介紹如何使用head.js實(shí)現(xiàn)網(wǎng)站并行加載但順序執(zhí)行JS,提高網(wǎng)站加載速度。需要的朋友可以看下
    2016-11-11
  • js實(shí)現(xiàn)div在頁面拖動效果

    js實(shí)現(xiàn)div在頁面拖動效果

    這篇文章主要介紹了js實(shí)現(xiàn)div在頁面拖動效果,涉及JavaScript動態(tài)操作頁面元素與數(shù)值計(jì)算的相關(guān)技巧,需要的朋友可以參考下
    2016-05-05
  • JS中用childNodes獲取子元素?fù)Q行會產(chǎn)生一個子元素

    JS中用childNodes獲取子元素?fù)Q行會產(chǎn)生一個子元素

    本文給大家分享JS中用childNodes獲取子元素?fù)Q行會產(chǎn)生一個子元素的實(shí)例代碼,需要的朋友參考下
    2016-12-12
  • webpack拆分壓縮css并以link導(dǎo)入的操作步驟

    webpack拆分壓縮css并以link導(dǎo)入的操作步驟

    我們運(yùn)行打包后會發(fā)現(xiàn)less轉(zhuǎn)為了css文件,但css文件確通過js加入style標(biāo)簽,下面我們將css進(jìn)行拆分出來,并以link標(biāo)簽引入,具體實(shí)現(xiàn)步驟一起看看吧
    2021-10-10
  • JS觸摸事件、手勢事件詳解

    JS觸摸事件、手勢事件詳解

    本篇文章主要介紹了JS觸摸事件、手勢事件詳解,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-05-05
  • 詳解Flutter如何用思源宋體炫出你的UI

    詳解Flutter如何用思源宋體炫出你的UI

    這篇文章主要為大家介紹了Flutter如何用思源宋體炫出你的UI示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-04-04

最新評論

五大连池市| 武邑县| 玉林市| 满洲里市| 葵青区| 洛隆县| 当雄县| 株洲市| 高要市| 渝北区| 冕宁县| 长汀县| 略阳县| 资兴市| 德格县| 阳原县| 琼结县| 叶城县| 朝阳市| 阜南县| 赞皇县| 行唐县| 河曲县| 正定县| 漳平市| 庐江县| 晴隆县| 延庆县| 视频| 岚皋县| 建昌县| 河津市| 长岛县| 吴川市| 深州市| 竹北市| 井冈山市| 丹巴县| 巫溪县| 泰宁县| 木兰县|