A deep dive into controlling infinite CSS animations beyond simple pause/play. Using animation-composition: add with a duplicated paused animation, you can accelerate, decelerate, stop, or reverse an already-running infinite animation without causing jumps or glitches. The technique uses CSS custom properties for a speed factor variable, and CSS math functions like abs() and sign() to create a single generic solution that handles all speed and direction cases. Practical examples include rotating elements, marquee animations, glowing borders, and interactive galleries.

12m read timeFrom frontendmasters.com
Post cover image
Table of contents
More Speed!Controlling the SpeedSlow Down!What about negative values?The Generic CodeMore ExamplesThe Math Behind The FormulaConclusion
1 Comment

Sort: