CSS
css/animate-composited
Animations and transitions change transform and opacity, not layout properties such as width, height, top, left or margin.
umiarkowanastatycznefe-motion
Dlaczego
Changing width, height, top, left, margin or padding makes the browser recalculate layout and repaint on every frame, often for the whole page around the element. On a mid-range phone that drops frames, delays input and can count as layout shift. transform and opacity can be animated by the compositor without layout.
Poprawka
Move with translate/transform: translate(), resize visually with scale (with transform-origin), fade with opacity. For an expanding panel, animate grid-template-rows from 0fr to 1fr or use a clip, and keep the motion short. Only add will-change to fix a measured problem.
Przykłady
/* bad */
.drawer { left: -20rem; transition: left 0.3s; }
.drawer.is-open { left: 0; }
/* good */
.drawer { translate: -100% 0; transition: translate 0.3s; }
.drawer.is-open { translate: 0 0; }Źródła
Fakty
- Identyfikator
css/animate-composited- Waga
- umiarkowana
- Sprawdzanie
- statyczne sprawdzane w kodzie źródłowym przez
audit - Dotyczy plików
cssscsslesshtmlvuesvelteastro- Uczy jej skill
fe-motionMotion and animation- Od wersji
- 0.1.0
Przeczytaj w terminalu
npx github:dawidolko/frontend-skills explain css/animate-composited