Capítulo 134 de 411
clamp() constrains a number to a min/max range — below the minimum returns the minimum, above the maximum returns the maximum, otherwise the number is unchanged.
| Signature | Description |
|---|---|
clamp(min, max, valueToClamp) | returns the clamped number immediately |
clamp(min, max) | returns a reusable function that clamps whatever you feed it later |
gsap.utils.clamp(0, 100, 105); // 100
const clampIt = gsap.utils.clamp(0, 100); // reusable
clampIt(105); // 100
clamp() to sanitize a value before further processing.