What I'm talking about here is the kind of uniform motion, mainly by changing the left and top values of a box die to achieve motion, or, changing the properties of the shape itself, to move:
function GetStyle (obj,name) {return Obj.currentstyle?obj.currentstyle[name]:getcomputedstyle (obj,false) [name];}; function Move (obj,json,options) {options=options| | {};options.time=options.time| | 700;var Start={};var Dis={};for (var name in JSON) {if (name== ' opacity ') {start[name]=parsefloat (GetStyle (Obj,name));} Else{start[name]=parseint (GetStyle (obj,name)); Dis[name]=json[name]-start[name];}; var count=math.round (OPTIONS.TIME/30), Var n=0;clearinterval (Obj.timer), Obj.timer=setinterval (function () {n++;for ( var name in json) {var cur=start[name]+dis[name]*n/count;if (name== ' opacity ') {Obj.style.opacity=cur;obj.style.filter = ' Alpha (opacity: ' +cur*100+ ') ';} else{obj.style[name]=cur+ ' px ';}}},30);}
GetStyle This function is to get the style properties, the previous piece has been said;
Here is the formula for moving the transport:
Start distance + (end distance-start distance) * movement several times/altogether can exercise how many times;
Starting distance here with start, the end distance with a JSON data, Json[name], is the end distance, n represents the movement of several times, the count represents, 30 milliseconds walk once, a specified time to walk the total number of distance.
Motion function move all kinds of motion can do