1 /*Perfect Motion Frame*/2 //1. Clear the Set period, 2, get the style, if it is opacity alone, 3, define the speed, 4, define whether the current value to reach the destination, 5, determine whether the current value to reach the destination, 6 movement basic, if it is opacity3 function startmove(obj,json,fnend) {4 clearinterval(obj.timer);5Obj.timer =setinterval(function(){6 varBstop =true; //Assuming all properties reach the target value 7 for(attrinchJSON) { //multivalued motion in JSON form 8 varCur = 0;9 if(attr== "Opacity") { //transparency Special handling TenCur=math.round (parsefloat (GetStyle (obj, attr)) *100); One}Else{ ACur =parseint (GetStyle (obj,attr)); - } - the varSpeed = (json[attr]-cur)/6;//define Speed -Speed = speed > 0?Math.ceil (Speed): Math.floor (speed); //Buffer motion rounding - - if(cur! = Json[attr]) { //If the values do not reach the target value, continue the motion +Bstop =false; - } + if(attr = = "Opacity") { //transparency Special handling AObj.style.filter= ' alpha (opacity: ' + (cur+speed) + ') '; atobj.style.opacity= (cur+speed)/100; -}Else{ -OBJ.STYLE[ATTR] = cur+speed + "px"; - } - } - if(bstop) { in clearinterval (Obj.timer); //If the values reach the target, stop the timer - if(fnend) { //callback function, chain-motion to fnend (); + } - } the},math.round (1000/60)); *}
2015.8.2js-19 (Perfect motion frame)