Capítulo 147 de 411
unitize() wraps another function so its result always gets a unit appended (and strips units from the input before calling it).
| Parameter | Type | Description |
|---|---|---|
fn | Function | the raw-number function to wrap |
unit | String | default "px" — unit to strip on input and re-add on output |
let clamp = gsap.utils.unitize(gsap.utils.clamp(0, 100), "px");
clamp(132); // "100px"
clamp() (which only understands raw numbers) so it can safely accept and return "px"-suffixed values.