Easing Functions
Functions for realistic animation
Alright, enough playing around — time to make your life a bit more complicated. The animate() method can take more than one argument, and it's time we broke them down. The argument set can vary; here's the first one, the simpler one:
properties
CSS properties — we've already covered this
duration
animation speed, mentioned before — specified in milliseconds, or using the keywords "fast" or "slow"
easing
specifies which function to use for changing values
complete
function that will be called after the animation ends
Of the listed parameters, only "easing" hasn't come up before — I was saving it for this moment. This parameter specifies which function will be used for the value animation process. These can be linear, quadratic, cubic, or any other functions. Out of the box, we can only choose between "linear":
and "swing":
If you peek into the jQuery source code, you'll easily find the corresponding code:
Want more easing functions? Then check out the easing plugin at https://gsgd.co.uk/sandbox/jquery/easing/ — it's truly a "must have".
As a guide to easing functions, you can use the page https://easings.net/.
I'll tell you how to write your own animation function a bit later.
Last updated