All effects
Parameter playground

Drag a slider: the demo replays itself so the difference is visible, and the matching number inside the prompt is rewritten. Copy it and you take a prompt tuned to your taste.

Snap bounce 1.56 The cursor hops to the next point: 1 sticks flat, 2.2 overshoots then snaps back
Glide time 0.3s Auto-hops: 0.1s tracks like a shadow, 0.6s floats over slowly
Charts

Magnetic Cursor + Odometer

Sweeping a chart snaps the cursor to data points magnetically while an odometer counter rolls in sync.

AI Prompt
Implement a line chart with a magnetic cursor: when swiping horizontally, the cursor snaps to the nearest data point with a slight elastic feel (overshoot bezier 1.56, glides in 0.3s), while the value at the top updates through an odometer/ticker rolling-digit animation in real time. Draw the chart with SVG, handle interaction with vanilla JS.

How it works

The widget chains two classic components through one shared state. The chart half is magnetic snapping: as the finger drags horizontally, the touch point is converted into chart coordinates, the nearest data point wins, and the cursor line plus dot glide over with transform: translateX on a spring-flavored transition - the landing has a tiny overshoot that reads as the cursor being physically pulled onto the point. The counter half is an odometer: every digit position is a vertical strip holding 0 through 9 stacked top to bottom, and changing the value just slides each strip with translateY to the target digit's row over about 300 milliseconds. Thousands separators are static glyphs that never move.

The linkage is one integer: whichever index the cursor snaps to becomes the value the odometer rolls to. One subtle requirement makes or breaks it - inside SVG, the cursor must be moved with transform, never by writing attribute coordinates, because attribute changes cannot transition on the compositor and will jump instead of glide on mid-range phones.

How to use this prompt

Use it for any time series users scrub through point by point: steps, revenue, battery, heart rate. Send the prompt with your data array and value range so the AI generates the correct coordinate mapping. If you have dozens of points, add one sentence - snap by pixel distance threshold instead of nearest point - which keeps dragging feeling 1:1 with the finger even on dense data.

Tips for better results

The odometer only looks right if each strip's row height exactly equals the line height of the digits; half a pixel off shows as clipped steps mid-roll. When values jump by large amounts, cap how fast the highest digit spins or the leading digit becomes a blur that steals the show. Set the snap radius to half the gap between adjacent points for seamless full coverage. On touch devices, call setPointerCapture on pointerdown so dragging that slides off the chart keeps tracking until the finger lifts - without it the cursor freezes at the chart edge.

Keep exploring