JavaScript motion framework: arbitrary motion of multiple objects (3) javascript framework
The first two articles are the motion of a single object. This article describes the motion of multiple objects. For example, different attributes of multiple Divs, such as width, height, font size, and transparency, buffer motion changes.
Since the beginning of this article, offsetWdith and offsetHeight will no longer be used, because there will be problems, such as adding a border and offsetWidth will cause serious problems, refer to the 'bug 'of offsetWidth in my blog JavaScript and its countermeasure solution is to encapsulate the getStyle (obj, attr) function and get the current value in the motion!
function getStyle(obj, name) { if(obj.currentStyle) {//IE return obj.currentStyle[name]; } else { return getComputedStyle(obj, false)[name]; }}
Since each object is moving independently, some variables cannot be shared between them. For example, a timer should have its own timer, because each time the timer is started, the previous Timer must be cleared first, this causes if the first object is still moving, move the mouse to the second object and immediately clear the previous timer. As a result, the motion of the first object cannot be moved to the target value.
In addition, there are two types of object motion styles: one is the size (px), and the other is the transparency!
<! DOCTYPE html>
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.