First look at the demo effect
code, function argument obj is the element that you want to change at the moment, changedata for the kind of change you want, for example, func the function you want to process after the element action ends
For example, to the above demo, Note: opacity to be multiplied by 100 for the following code
var div = document.getelementsbyclassname (' demo ') [0];
Startmove (Div, {width:200, height:200, left:100, top:100, opacity:50}, function () {});
/* * Motion Function Model * * functions startmove (obj, Changedata, func) {clearinterval (Obj.timer);
var icurvalue = 0;
var ispeed = 0;
var bstop; Obj.timer = Window.setinterval (function () {bstop = true;//to determine whether all current actions are fully executed for (var name in Changedata)
{Console.log (name, Changedata[name]);
if (name = = = = = ' opacity ') {//When processing transparency to pay attention to increase the multiple, otherwise easy to cause the bug Icurvalue = parsefloat (GetStyle (obj, name)) * 100;
}else {icurvalue = parseint (GetStyle (obj, name)); } Ispeed = (Changedata[name]-icurvalue)/7;//buffering Motion effect if (Ispeed > 0) {ispeed
= Math.ceil (ispeed);
}else{ispeed = Math.floor (ispeed);
} if (name = = = ' opacity ') {obj.style.opacity = (Icurvalue + ispeed)/100;
}else{Obj.style[name] = icurvalue + ispeed + ' px '; } if (Icurvalue !== Changedata[name]) {bstop = false;
} if (bstop) {//entire action completed clearinterval (Obj.timer);
Func ()//////////////////////
}, 30);
}