The jquery effect function (Slideup (), FadeIn (), and so on) and the animation () function all receive another parameter that controls the speed of the animation process, which is the easing (easing), which determines the speed of the animation process at different times. For example, when you move an element across a page, you may let the element start moving slowly, then quickly, and then slow down again as the animation completes. Add ease to the animation, making the animation more visually interesting and more dynamic.
jquery contains only two easing methods: swing and linear. The linear method provides a steady animation so that each step of the animation is the same (for example, if you want an element to pass through the screen in a gradual fashion, the distance between each step is the same as the previous step). Swing is a bit more dynamic, as the animation begins to get faster and then slow down. Swing is a common setting, so if you don't specify any easing, jquery uses the Swing method.
For any jquery effect, the easing method is its second parameter, so you can write code by using the linear method to slide an element out of view:
Copy Code code as follows:
$ (' #element '). Slideup (1000, ' linear ');
When using the animate () function, the easing method is the third parameter, the first parameter is a direct amount of the object, contains the CSS attributes we want to animate, and the second parameter is the overall speed of the animation. For example, to use the linear easing method for animation code, you can write code as follows:
Copy Code code as follows:
$ (' #message '). Animate (
{
Left: ' 650px ',
Opacity:.5,
FontSize: ' 24px '
},
1500,
' Linear '
);
However, it is not limited to using the two easing methods provided by jquery. Use the jquery plug-in to add a series of other easing methods.