motion
How animations and transitions work in EasyTask - the animation speed preference (System, Slow, Normal, None) applied as data-motion on the root, the CSS rules that scale or stop them, durations in JS
Files1
View on GitHubSKILL.md.claude/skills/motion/SKILL.md
GitHubAnimations (EasyTask)
Every animation follows the user's preference Impostazioni > Aspetto > Velocità delle animazioni (animationSpeed: system, slow, normal, none). Nothing may move at its own speed.
How the speed reaches the page
src/lib/animation-speed.ts:applyAnimationSpeedwritesdata-motionon<html>(slow|normal|none).systemis resolved tononewhen the OS asks for reduced motion (prefers-reduced-motion), otherwisenormal, and follows OS changes live. Called fromcontexts/preferences-context.tsx.src/index.css(after@layer utilities):slow= the original Tailwind durations (150ms), nothing overridden;normal=--default-transition-duration: 90msand--tw-animation-duration: 100ms(tw-animate-css, set on every element because the variable does not inherit);none= every animation and transition at 1ms, not 0: Radix components wait for the end of their exit animation to unmount..animate-spinkeeps turning (it says something is running);.animate-pulse(skeletons) stops.
Writing an animation
- Prefer the existing machinery: Tailwind
transition-*with the default duration, tw-animate-css classes (animate-in fade-in-0 zoom-in-95, the ones shadcn components already use). They followdata-motionwith no extra code. - A fixed duration (
duration-300,animation: x 1.2s) does NOT follownormal/slow: add rules for:root[data-motion="slow"]and:root[data-motion="none"]next to the keyframes, like.loading-dotand.live-drag-slotinindex.css. - With the animations off the element is in its final state, still and visible (
opacity: 1, no transform), not hidden. - Before the preference is applied (first paint) add
@media (prefers-reduced-motion: reduce) { :root:not([data-motion]) ... }as.loading-dotdoes. - Durations in JS (WAAPI,
setTimeoutwaiting for an animation, rAF-driven moves): read them fromshiftDurationMs(base)(0 / base / base ×SLOW_MOTION_RATIO), never a literal. Read it once at the start of the gesture. - Animate only
opacityandtransform(no width, height, top/left, filter, box-shadow): they stay on the compositor, also on WebKitGTK, and do not trigger layout of the note. - Purpose: an animation confirms an action or shows a state (opening, appearing, saving, loading). No decorative loops; an infinite animation needs a reason (loading) and must stop with
noneunless it is a spinner. - Components to reuse:
components/loading-dots.tsx(LoadingDots),ui/progress-ring.tsx,ui/skeleton.tsx, shadcndialog/popover/dropdown-menu/sheet/tooltip(already animated).
Engines
The app runs on WebView2 (Chromium, Windows), WebKitGTK (Linux) and WebKit (macOS). Avoid features only Chromium has without a fallback: View Transitions, scroll-driven animations, @starting-style, interpolate-size. Check them with the skill modern-web-guidance and keep a plain fallback (no animation) where unsupported.
Tests
- Unit:
src/lib/animation-speed.test.ts(resolution ofsystem,shiftDurationMs). For a component, assert the class or thedata-*state, not the timing (jsdom does not animate). - e2e (skill e2e-spec): set the speed to
noneand check the final state is shown at once; withnormalcheck the class is present. Do not wait on real durations. - By hand, for the PR: the four speeds, the OS "reduce motion" (Windows: Settings > Accessibility > Visual effects > Animation effects) with
system, and a look on Linux if possible.