animation-timing-function
Example
.spinner {
animation: spin 1s infinite;
}.spinner {
animation: spin 1s linear infinite;
}'linear' keeps the rotation speed constant, while the default 'ease' slows down at the start and end of each turn.
Common mistakes
- A spinner speeds up and slows down on each turn because the default is 'ease'.
- Expecting one easing curve across all keyframes, while it repeats between each pair.
Key points
- Spinners and progress loops use 'linear', so the speed doesn't pulse on each cycle.
- Custom curves use
cubic-bezier()orlinear(), not extra keyframes that fake easing. - Easing is understood to apply to each segment between keyframes, not across the whole animation.
Interview questions
What is the default animation-timing-function?
'ease', which starts slowly, speeds up and slows down again at the end.
Can I use steps() for sprite animations?
Yes. steps(8) jumps between 8 frames with no values in between, which suits sprite sheets and typing effects.