general
will-change
Applies will-change, hinting the browser to optimize for an upcoming animation on the given property/properties before it starts.
import { willChange } from "@sdxc/u/general";Quick reference
Every documented call, beside the CSS it emits.
| Call | CSS |
|---|---|
u.willChange("transform") | css({ willChange: "transform" }) |
u.willChange("opacity, transform") | css({ willChange: "opacity, transform" }) |
Using a custom value
Every scale argument also takes a raw CSS value, which passes through untouched.
u.willChange("transform")Applying on a state
Wrap the call in a state utility to scope it to one selector.
u.hover(u.willChange("transform"))Responsive design
Wrap the call in a container query to scope it to one width.
u.at("md", u.willChange("transform"))Signature
u.willChange(value: WillChangeValue)