zoukankan      html  css  js  c++  java
  • 完美运动框架

     1 function getByClass(oParent,sClass)
     2 {
     3     var aEle=document.getElementsByTagName('*');
     4     var i=0;
     5     var aResult=[];
     6     
     7     for(i=0;i<aEle.length;i++)
     8     {
     9         if(aEle[i].className==sClass)
    10         {
    11             aResult.push(aEle[i]);
    12         }
    13     }
    14     return aResult;
    15 }
    16 function getStyle(obj,attr)
    17 {
    18     if(obj.currentStyle)
    19         {
    20             return obj.currentStyle[attr];
    21         }
    22     else
    23         {
    24             return getComputedStyle(obj,false)[attr];
    25         }
    26 }
    27 function startMove(obj, attr,iTarget)
    28 {
    29     
    30     clearInterval(obj.timer);
    31     obj.timer=setInterval(function(){
    32         var iCur=0;
    33         if(attr=='opacity')
    34             {
    35                 iCur=parseFloat(getStyle(obj,attr))*100;
    36             }
    37         else
    38             {
    39                 iCur=parseInt(getStyle(obj,attr));
    40             }
    41         var iSpeed=(iTarget-iCur)/8;
    42         iSpeed=iSpeed>0?Math.ceil(iSpeed):Math.floor(iSpeed);
    43         
    44         if(iCur==iTarget)
    45             {
    46                 clearInterval(obj,timer);
    47             }
    48         else
    49             {
    50                 if(attr=='opacity')
    51                     {
    52                         obj.style.filter='alpha(opacity:'+(iCur+iSpeed)+')';
    53                         obj.style.opacity=(iCur+iSpeed)/100;    
    54                     }
    55                 else
    56                     {
    57                         obj.style[attr]=iCur+iSpeed+'px';
    58                     }
    59             }
    60     },30)
    61 }
  • 相关阅读:
    Mac 国内安装homebrew办法
    字符串方法及注释
    文件的操作
    集合
    Mac下CVS文件编码转换
    字符串格式化
    postman常用断言的一些内置方法
    get与post区别
    pygame知识点(持续更新)
    记录第一次使用
  • 原文地址:https://www.cnblogs.com/xiaofanke/p/3678705.html
Copyright © 2011-2022 走看看