This paper summarizes the knowledge points of JS movement. Share to everyone for your reference, specific as follows:
1. Multi-Object Motion framework nothing can be shared.
2.document.title output frequency is not too high
3. When writing JS, try to avoid writing decimal, because the internal computer is simulated, not the actual storage
such as: 0.07*100 in the JS operation is not for 7
var a=3;
var b=3.00000000000000000001;
alert (A=B);
The result of the output is true
4. Write program thinking before thinking general, and then thinking special, write program is, first exclude special, and then write general
if (special 1)
{}
else if (special 2)
{}
else
{
General
}
5. Arrays can be used for either a for loop or a for ... In loop, because the for loop is more controllable, so the For loop is better
Object (JSON) can only be used for ... In loop
6. *{margin:0;padding:0 in CSS; This is not a good write performance.
7. Layout conversion, first set the Left,top value for each element, all set up to give each element position set absolute and margin clear zero
8.ie7 in the use of UL sports will card, this time can use Div to try
9. Consider the friction factor ispeed*0.95 (the size of the decimal number depends on the size of the friction)
10. Acceleration, the farther the acceleration from the target, the nearer the target, the smaller (itarget-obj.offsetleft)/50
11. The combination of acceleration and friction is 5 and 0.7, i.e. ispeed+= (itarget-obj.offsetleft)/5; ispeed*=0.7;
12. When the program goes wrong, think about why this problem occurs
13. The elastic movement cannot be used when the style cannot cross the boundary
14. Elastic Motion Stop Condition: the distance too near speed too small
15. Analysis to onlookers analysis, because the style will automatically ignore decimals, so in order not to let the missing decimal add up, you can set a variable to store, and then assign to the style. obj.style.left=left+ "px";
Attached: JavaScript Elastic motion Examples
Motion principle: Acceleration Movement + deceleration movement + friction movement;
The code is as follows:
More about JavaScript motion effects to view the site topics: "JavaScript movement effect and Skills summary"
I hope this article will help you with JavaScript programming.