Four optimization methods of JS implementation animation
- 1) If you are using the settimeout implementation of the polling animation, before each execution of the method need to put the previous set of timer removed
- 2) in order to prevent the pollution of global variables, we assign the return value of the timer to the custom property of the current operation element; There is also the benefit of doing the next animation if the current animation is not completed, because each time we give ourselves a custom attribute, Then the next animation at the beginning of the default to the current animation of the end;
- 3) about the problem of scope accumulation in move write a _move to perform our animation operation, _move inside does not need to pass parameters, each time with the value stored in the move can be
- 4) in order to prevent a step super, do not go to the border, we do boundary judgment when we need to add step to do
Four optimization methods of JS implementation animation