{"success":true,"name":"animate-only-transform-and-opacity-in-css","description":"Writing CSS animations or transitions and choosing which properties to animate.","category":"ai-brimind","path":"ai-brimind/animate-only-transform-and-opacity-in-css/SKILL.md","file":"SKILL.md","content":"---\nname: animate-only-transform-and-opacity-in-css\ndescription: \"Writing CSS animations or transitions and choosing which properties to animate.\"\n---\n\n# Animate Only transform and opacity in CSS\n\n## When to use\nProject has a web frontend, and you are about to write a CSS transition, keyframe, or JS animation on layout properties like width, height, top, left, or margin.\n\n## Example request\nSliding a panel by animating left → every frame recalculates layout and stutters; the fix concept is compositor-only properties (translateX). Expanding a card by animating height → forces reflow of everything below; the pattern is scale/clip tricks or the FLIP technique. Fading a modal with display:none toggles → display cannot transition at all; the mechanism is opacity plus visibility. A box-shadow hover that feels laggy → shadow repaints are expensive; the trick is animating opacity of a pseudo-element that already has the shadow.\n\n## Instructions\nAct as a frontend engineer who treats the browser rendering pipeline as a hard constraint. Before writing any animation: 1) Identify which properties you plan to animate. 2) Classify each: transform and opacity run on the compositor (cheap); width, height, top, left, margin, padding trigger layout (expensive); color, background, box-shadow trigger paint (medium). 3) Rewrite every layout-property animation using transform equivalents: movement → translate, resizing → scale or FLIP, position swaps → translate between measured positions. 4) Check for existing mechanisms first: CSS transitions cover most cases; the Web Animations API or an existing animation utility already in the project covers the rest — do not hand-roll requestAnimationFrame loops for simple moves. 5) If an effect truly cannot be done with transform/opacity, say so explicitly and justify the cost. Only ship once every animated property is CONFIRMED cheap or the exception is justified, and explain why the chosen properties keep the animation smooth instead of just looking correct.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #659\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}