Skip to content

176 web animation techniques, each a live demo with plain settings and a ready-made prompt for your AI assistant. No dependencies, no build step.

docs: add the frame-loop rule to CLAUDE.md and CONTRIBUTING.md

matindc28b385cf92
diff --git a/CLAUDE.md b/CLAUDE.md
index e174b5e9..da7bf9d4 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -262,6 +262,14 @@ This is non-negotiable — a demo that breaks on phones fails the quality bar.
`(max-width:600px),(max-height:500px)`, so a phone held sideways counts.
- Use `transform` and `opacity` for animations — never animate `width`,
`height`, `top`, `left`, or `box-shadow` directly.
+- A JavaScript frame loop moves by elapsed time, never by a fixed amount per frame, or it runs twice as fast on a
+ 120 Hz screen and half as fast on a 30 Hz phone (the page check runs at 60 Hz and cannot see it). With
+ `FRAME = 1000 / 60` and `dt = lastT === null ? 0 : Math.min(ts - lastT, 50)` (a start, Play and `visibilitychange`
+ set `lastT = null`; an easing that restarts on input may count its first frame as one `FRAME`), multiply each step
+ by `dt / FRAME` (and by 1/3 in Slow motion) and turn an easing share `k` into `1 - Math.pow(1 - k, dt / FRAME)`.
+ Physics that needs equal steps (Verlet, a spring) takes fixed steps from an accumulator. A trail washes once for
+ every 60th of a second at its 60 Hz opacity, and a frame with no wash due draws nothing. Copy the loop of Synthwave
+ Grid, Starfield (trails) or Cloth Simulation (fixed steps).
- Respect `@media (prefers-reduced-motion: reduce)` — disable or simplify
animations for users who request it (see Reduced motion above).
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 9378fd26..52644c20 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -198,6 +198,9 @@ Every demo must work on mobile, tablet, and desktop.
- Touch targets are at least **44×44px**; gate hover effects behind `@media (hover: hover)`.
- Drag interactions use Pointer Events, not mouse events.
- Animate `transform` and `opacity` only — never `width`, `height`, `top`, `left`, or `box-shadow`.
+- A JavaScript frame loop moves by the time since the last frame (in 60ths of a second, at most 50 ms), never by a
+ fixed step per frame, so it runs at the same speed on every screen. Copy the loop of Synthwave Grid, Starfield
+ (trails that fade) or Cloth Simulation (physics in fixed steps).
- Text is at least 4.5:1 against its background.
- Respect `@media (prefers-reduced-motion: reduce)`.