The last challenge introduced theanimation-timing-functionproperty and a few keywords that change the speed of an animation over its duration. CSS offers an option other than keywords that provides even finer control over how the animation plays out, through the use of Bezier curves.
In CSS animations, Bezier curves are used with thecubic-bezierfunction. The shape of the curve represents how the animation plays out. The curve lives on a 1 by 1 coordinate system. The X-axis of this coordinate system is the duration of the animation (think of it as a time scale), and the Y-axis is the change in the animation.
Thecubic-bezierfunction consists of four main points that sit on this 1 by 1 grid:p0,p1,p2, andp3.p0andp3are set for you - they are the beginning and end points which are always located respectively at the origin (0, 0) and (1, 1). You set the x and y values for the other two points, and where you place them in the grid dictates the shape of the curve for the animation to follow. This is done in CSS by declaring the x and y values of thep1andp2"anchor" points in the form:(x1, y1, x2, y2). Pulling it all together, here's an example of a Bezier curve in CSS code:
In the example above, the x and y values are equivalent for each point (x1 = 0.25 = y1 and x2 = 0.75 = y2), which if you remember from geometry class, results in a line that extends from the origin to point (1, 1). This animation is a linear change of an element during the length of an animation, and is the same as using thelinearkeyword. In other words, it changes at a constant speed.
For the element with the id ofball1, change the value of theanimation-timing-functionproperty fromlinearto its equivalentcubic-bezierfunction value. Use the point values given in the example above.