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

     1 /**
     2  * Created by linxd on 2015/6/6.
     3  */
     4 
     5 
     6 function getStyle(obj, name) {
     7     if (getComputedStyle) {
     8         return getComputedStyle(obj, null)[name];
     9     } else {
    10         return obj.currentStyle[name];
    11     }
    12 }
    13 
    14 function startMove(obj, json, fnEnd) {
    15     clearInterval(obj.timer);
    16     obj.timer=setInterval(function () {
    17         var bStop = true;
    18         for (var attr in json) {
    19             var cur = 0;
    20             if (attr == "opacity") {
    21                 cur = Math.round(parseFloat(getStyle(obj, attr))*100);
    22             } else {
    23                 cur = parseInt(getStyle(obj, attr));
    24             }
    25             var speed = (json[attr]-cur)/6;
    26 
    27             speed=speed>0? Math.ceil(speed):Math.floor(speed);
    28 
    29             if (cur != json[attr]) {
    30                 bStop = false;
    31             }
    32 
    33             if (attr == "opacity") {
    34                 obj.style.filter = "alpha(opacity:" + (cur+speed) + ")";
    35                 obj.style.opacity = (cur+speed)/100;
    36             } else {
    37                 obj.style[attr] = cur + speed + "px";
    38             }
    39         }
    40 
    41         if (bStop) {
    42             clearInterval(obj.timer);
    43             if (fnEnd) fnEnd();
    44         }
    45     }, 30);
    46 }

    http://bbs.zhinengshe.com/thread-1198-1-1.html

  • 相关阅读:
    JSON
    邮箱正则表达式
    聚聚科技---PHP开发笔试题及答案
    PHP字符串左边补0,字符串右边补0
    CSS3实现带阴影的弹球
    背景颜色渐变
    CSS3---滤镜
    CSS3裁剪与遮罩解析
    CSS3---混合模式
    使用CSS3制作各种形状
  • 原文地址:https://www.cnblogs.com/linxd/p/4558520.html
Copyright © 2011-2022 走看看