JS Animation Learning (I.)

Source: Internet
Author: User

First, the realization of the idea of the motion framework

1. Uniform motion (constant change in attribute values) (change left, right, width, height, opacity, etc.);

2. Buffer motion (the rate of change in the property value is proportional to the difference between the current value and the target value);

3. Multi-object movement;

4. Change of any attribute value (with encapsulation function);

5. Chain movement (the same object completes a series of motions);

6. Simultaneous movement of multiple objects

====================================================

Ii. the uniform motion of simple movement

1 // mouse moves the element to the right, and the mouse leaves the element back.

2 var timer= "";

3 function Move (speed,locat) {// move speed, move end position

4 var ob=document.getelementbyid (' box1 ');

5 clearinterval (timer);

6 timer=setinterval (function () {

7 if (ob.offsetleft==locat) {// The current position reaches the specified end point, turn off the timer

8 clearinterval (timer);

9 } else {

ten ob.style.left=ob.offsetleft+speed+ ' px ';

One }

(+)

-}

JS Animation Learning (I.)

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.