标签:logs function false ted time else target pre tco
1 function getStyle(obj,attr){ 2 if(obj.currentStyle){ 3 return obj.currentStyle[attr] 4 }else{ 5 return getComputedStyle(obj)[attr] 6 } 7 } 8 function startMove(obj,json,fn){ 9 clearInterval(obj.timer); 10 obj.timer=setInterval(function(){ 11 var stops=true; 12 for(var name in json){ 13 var target=parseInt(parseFloat(json[name])); 14 var cur=parseInt(parseFloat(getStyle(obj,name))); 15 var speed=(target-cur)/30; 16 speed=speed>0?Math.ceil(speed):Math.floor(speed); 17 obj.style[name]=speed+cur+"px"; 18 if(cur!=target){ 19 stops=false; 20 } 21 } 22 if(stops){ 23 clearInterval(obj.timer); 24 if(fn){ 25 fn() 26 } 27 } 28 },20) 29 }
标签:logs function false ted time else target pre tco
原文地址:http://www.cnblogs.com/chaojimali/p/6888778.html