标签:asc style 设置 UNC etc ons compute city pac
function getStyle(obj, name) { return obj.currentStyle ? obj.currentStyle[name] : getComputedStyle(obj)[name]; }//获取元素的非行间样式 function move(obj, json, options) { clearInterval(obj.timer); options.time=options.time||500;//设置默认时间 options.easeing=options.easeing||‘ease-out‘;//设置默认运动形式 var start={}; var target={}; for (var name in json){ start[name] = parseFloat(getStyle(obj, name));//将运动前的属性值存到一个start里面 target[name]=json[name]-start[name];//将需要运动的属性值存到target里面 }; var count = parseInt(options.time / 10);//设置步长 var n = 0; obj.timer = setInterval(function () { n++; for (var name in json){ switch (options.easeing) { case ‘linear‘: var a=n/count; var current=start[name]+target[name]*a;//匀速 break; case ‘ease-in‘: var a=n/count; var current=start[name]+target[name]*(a*a*a);//匀加速 break; case ‘ease-out‘: var a=1-n/count; var current=start[name]+target[name]*(1-a*a*a);//匀减速 break; } if (name===‘opacity‘){ obj.style[name]=current; }else { obj.style[name]=current+‘px‘; }; }; if (n === count) { clearInterval(obj.timer); options.fn && options.fn(); } }, 10) };
标签:asc style 设置 UNC etc ons compute city pac
原文地址:https://www.cnblogs.com/cz0017/p/10390973.html