星空网 > 软件开发 > Java

JavaScript 智能社 完美运动框架

 简约版:

function getStyle(obj, name){  if(obj.currentStyle)  {    return obj.currentStyle[name];  }  else  {    return getComputedStyle(obj, false)[name];  }}function startMove(obj, attr, iTarget, fnEnd){  clearInterval(obj.timer);  obj.timer=setInterval(function (){    var cur=0;        if(attr=='opacity')    {      cur=Math.round(parseFloat(getStyle(obj, attr))*100);    }    else    {      cur=parseInt(getStyle(obj, attr));    }        var speed=(iTarget-cur)/6;    speed=speed>0?Math.ceil(speed):Math.floor(speed);        if(cur==iTarget)    {      clearInterval(obj.timer);            if(fnEnd)fnEnd();    }    else    {      if(attr=='opacity')      {        obj.style.filter='alpha(opacity:'+(cur+speed)+')';        obj.style.opacity=(cur+speed)/100;      }      else      {        obj.style[attr]=cur+speed+'px';      }    }  }, 30);}

完整版:

function getStyle(obj, name){  if(obj.currentStyle)  {    return obj.currentStyle[name];  }  else  {    return getComputedStyle(obj, false)[name];  }}//startMove(oDiv, {width: 400, height: 400})function startMove(obj, json, fnEnd){  clearInterval(obj.timer);  obj.timer=setInterval(function (){    var bStop=true;    //假设:所有值都已经到了        for(var attr in json)    {      var cur=0;            if(attr=='opacity')      {        cur=Math.round(parseFloat(getStyle(obj, attr))*100);      }      else      {        cur=parseInt(getStyle(obj, attr));      }            var speed=(json[attr]-cur)/6;      speed=speed>0?Math.ceil(speed):Math.floor(speed);            if(cur!=json[attr])        bStop=false;            if(attr=='opacity')      {        obj.style.filter='alpha(opacity:'+(cur+speed)+')';        obj.style.opacity=(cur+speed)/100;      }      else      {        obj.style[attr]=cur+speed+'px';      }    }        if(bStop)    {      clearInterval(obj.timer);                  if(fnEnd)fnEnd();    }  }, 30);}

 




原标题:JavaScript 智能社 完美运动框架

关键词:JavaScript

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

实际有效的8个最佳Facebook广告模板:https://www.ikjzd.com/articles/129093
发货限制疑似取消,亚马逊热销类目突遭“大屠杀”:https://www.ikjzd.com/articles/129094
Facebook广告营销怎么做?Facebook广告投放策略指南!:https://www.ikjzd.com/articles/129095
关键词快速上首页!竞品流量入口在哪?:https://www.ikjzd.com/articles/129096
中国卖家如何掘金拉美市场?:https://www.ikjzd.com/articles/129097
亚马逊全球开店为亚马逊卖家提供了哪些帮助:https://www.ikjzd.com/articles/12911
合肥有什么约会的地方好玩的地方 合肥哪里适合情侣好玩的地方:https://www.vstour.cn/a/411237.html
曾家山滑雪场-曾家山滑雪场号码:https://www.vstour.cn/a/411238.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流