Spring: Follow Cursor
An example of a spring animation that follows the cursor.
Introduction
The Spring: Follow Cursor example shows how to create a smooth, spring-based animation that follows your cursor around the screen. Instead of snapping instantly to the pointer position, the ball bounces and settles naturally, mimicking real-world physics.
This example uses three core Motion APIs: springValue creates animated values with spring physics, styleEffect automatically applies those values to element styles, and animate provides the underlying animation engine.
Spring animations are perfect for cursor followers because they create natural-feeling motion. Unlike linear animations that move at a constant speed, springs accelerate and decelerate smoothly, creating more organic and visually appealing movement.
