国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

JS模擬酷狗音樂播放器收縮折疊關閉效果代碼

2019-11-20 11:23:14
字體:
來源:轉載
供稿:網友

本文實例講述了JS模擬酷狗音樂播放器收縮折疊關閉效果代碼。分享給大家供大家參考,具體如下:

這是一款模擬酷狗音樂播放器的關閉特效,采用JavaScript實現,關閉的時候播放界面縮成一條線,然后消失,就像有些電視機突然停電的效果,很有意思的網頁動畫特效。

運行效果截圖如下:

在線演示地址如下:

http://demo.VeVB.COm/js/2015/js-kugou-music-player-style-demo/

具體代碼如下:

<!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>酷狗音樂播放器的關閉特效,采用JavaScript實現</title><style type="text/css">* { padding:0px; margin:0px;}#outer { width:952px; height: 640px; position:absolute; left:100px; top:20px; }#div1 { width:952px; height: 640px; overflow:hidden;  position:absolute;font-size:0px;}#div1 a { position:absolute; width:23px; height:21px; right:5px; top:5px; display:block; z-index:100; background:url(images/kugou.jpg) no-repeat 957px 645px;}#div1 a:hover { background:url(images/hover.jpg) no-repeat right top;}#line { height:3px; width:952px; display:none; z-index:100; position:absolute; left:0px; top:0px; font-size:0px;}#light{ /*width:50px; height:10px;*/ position:absolute; left:50%; top:50%;/* margin-left:-25px; margin-top:-5px;*/ width:0px; height:0px; filter:alpha(opacity:0);opacity:0;); overflow:hidden;}</style><script type="text/javascript">function css(obj, attr, value){ if(arguments.length==2) {  if(attr!='opacity')  {   return parseInt(obj.currentStyle?obj.currentStyle[attr]:document.defaultView.getComputedStyle(obj, false)[attr]);  }  else  {   return Math.round(100*parseFloat(obj.currentStyle?obj.currentStyle[attr]:document.defaultView.getComputedStyle(obj, false)[attr]));  } } else if(arguments.length==3)  switch(attr)  {   case 'width':   case 'height':   case 'paddingLeft':   case 'paddingTop':   case 'paddingRight':   case 'paddingBottom':   value=Math.max(value,0);   case 'left':   case 'top':   case 'marginLeft':   case 'marginTop':   case 'marginRight':   case 'marginBottom':    obj.style[attr]=value+'px';    break;   case 'opacity':    obj.style.filter="alpha(opacity:"+value+")";    obj.style.opacity=value/100;    break;   default:    obj.style[attr]=value;  } return function (attr_in, value_in){css(obj, attr_in, value_in)};}var MIAOV_MOVE_TYPE={ BUFFER: 1, FLEX: 2};//jsonfunction miaovStopMove(obj){ clearInterval(obj.timer);}function miaovStartMove(obj, oTarget,iSpeedCtrol, iType, fnCallBack, fnDuring){ var fnMove=null; if(obj.timer) {  clearInterval(obj.timer); } switch(iType) {  case MIAOV_MOVE_TYPE.BUFFER:   fnMove=miaovDoMoveBuffer;   break;  case MIAOV_MOVE_TYPE.FLEX:   fnMove=miaovDoMoveFlex;   break; } obj.timer=setInterval(function (){  fnMove(obj, oTarget,iSpeedCtrol, fnCallBack, fnDuring); }, 30);}function miaovDoMoveBuffer(obj, oTarget,iSpeedCtrol, fnCallBack, fnDuring){ var bStop=true; var attr=''; var speed=0; var cur=0; for(attr in oTarget) {  cur=css(obj, attr);  if(oTarget[attr]!=cur)  {   bStop=false;   speed=(oTarget[attr]-cur)/iSpeedCtrol;   speed=speed>0?Math.ceil(speed):Math.floor(speed);   css(obj, attr, cur+speed);  } } if(fnDuring)fnDuring.call(obj); if(bStop) {  clearInterval(obj.timer);  obj.timer=null;  if(fnCallBack)fnCallBack.call(obj); }}function miaovDoMoveFlex(obj, oTarget,iSpeedCtrol, fnCallBack, fnDuring){ var bStop=true; var attr=''; var speed=0; var cur=0; for(attr in oTarget) {  if(!obj.oSpeed)obj.oSpeed={};  if(!obj.oSpeed[attr])obj.oSpeed[attr]=0;  cur=css(obj, attr);  if(Math.abs(oTarget[attr]-cur)>=1 || Math.abs(obj.oSpeed[attr])>=1)  {   bStop=false;   obj.oSpeed[attr]+=(oTarget[attr]-cur)/iSpeedCtrol;   obj.oSpeed[attr]*=0.7;   css(obj, attr, cur+obj.oSpeed[attr]);  } } if(fnDuring)fnDuring.call(obj); if(bStop) {  clearInterval(obj.timer);  obj.timer=null;  if(fnCallBack)fnCallBack.call(obj); }}</script><script type="text/javascript">window.onload=function(){ var oDiv1 = document.getElementById('div1'); var oAbtn = oDiv1.getElementsByTagName('a')[0]; var oImg1 = document.getElementById('img1'); var oImg2 = document.getElementById('img2'); var oImg3 = document.getElementById('img3'); var oLine = document.getElementById('line'); var oLight = document.getElementById('light'); oAbtn.onclick=function(){  miaovStartMove(oDiv1, {height:3,marginTop:315},1.5, MIAOV_MOVE_TYPE.BUFFER,function(){   oImg1.style.display='none';   oLine.style.display='block';   miaovStartMove(oDiv1, {width:0,marginLeft:476},2, MIAOV_MOVE_TYPE.BUFFER);   miaovStartMove(oLine, {width:0},2, MIAOV_MOVE_TYPE.BUFFER);   miaovStartMove(oImg2, {width:0},2, MIAOV_MOVE_TYPE.BUFFER,function(){    miaovStartMove(oImg3, {width:200,height:10},1, MIAOV_MOVE_TYPE.BUFFER);    miaovStartMove(oLight, {width:200,height:10,marginLeft:-100,marginTop:-5,opacity:100},1, MIAOV_MOVE_TYPE.BUFFER,function(){     miaovStartMove(oLight, {opacity:0},1, MIAOV_MOVE_TYPE.BUFFER);     });    });   });  }}</script></head><body><div id="outer"> <div id="light"><img id="img3" src="images/line1.png" style="width:0px; height:0px;"/></div> <div id="div1"> <img id="img1" src="images/kugou.jpg" style="height:640px; width:952px; z-index:-3;"/> <a href="#"></a> <div id="line">  <img id="img2" src="images/line.png" style=" width:952px; height:3px;" /> </div> </div></div></body></html>

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

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 山东省| 齐河县| 仪陇县| 和林格尔县| 区。| 曲松县| 射阳县| 五河县| 大渡口区| 湟源县| 林甸县| 玉山县| 仪陇县| 宝山区| 武义县| 阜新| 习水县| 阜康市| 安多县| 丽水市| 拉萨市| 大方县| 山阴县| 田东县| 会昌县| 武陟县| 静宁县| 文昌市| 二连浩特市| 淮南市| 枣强县| 方正县| 鄂伦春自治旗| 乐昌市| 会同县| 双柏县| 朝阳县| 富民县| 嘉义县| 绥芬河市| 筠连县|