function Startmove (obj, JSON, func) {
Clearinterval (Obj.timer);
Obj.timer = setinterval (function () {
var bstop = true;
Take out the initial value of the attribute
for (Var attr in JSON) {
var icur = 0;
if (attr = = "opacity") {
Icur = parsefloat (GetStyle (obj, attr)) * 100;
}else{
Icur = parseint (GetStyle (obj, attr))
}
var speed = (json[attr]-icur)/8; 8 scaling factor, cushioning the best scaling factor for motion effects
Speed = speed > 0? Math.ceil (Speed): Math.floor (speed);
The program cannot continue as long as there is a value that does not reach the specified value
if (icur! = Json[attr]) {
Bstop = false;
}
if (attr = = "opacity") {
Obj.style.filter = "Alpha (opacity:" + (Icur + speed) + ")";
Obj.style.opacity = (icur + speed)/100;
}else{
OBJ.STYLE[ATTR] = icur + speed + "px";
}
}
if (bstop) {
Clearinterval (Obj.timer);
if (func) {
Func ();
}
}
}, 30);
}
Get non-inline styles
function GetStyle (obj, attr) {
if (Obj.currentstyle) {
return obj.currentstyle[attr]; IE9 below
}else{
return getComputedStyle (obj) [attr]; IE9 and Standard Browser
}
}
Multi-Object motion JavaScript function encapsulation