JavaScript motion framework: arbitrary motion of multiple objects (3) javascript framework

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.