What problem does it solve?
GSAP.utils provides a collection of small, composable helpers to perform common animation-related calculations, such as clamping values, mapping ranges, normalizing, interpolating, and randomizing or snapping values, reducing boilerplate in GSAP-driven code.
Core Features & Use Cases
- Clamp values to a range with gsap.utils.clamp(min, max, value) or its functional form.
- Map inputs to outputs using gsap.utils.mapRange(inMin, inMax, outMin, outMax, value?) and its function form.
- Normalize / Interpolate between numbers, colors, and objects with gsap.utils.normalize and gsap.utils.interpolate.
- Random / Snap / Wrap utilities to generate random values, snap to steps, or wrap ranges for cyclic animations.
- Use in ScrollTrigger, tween callbacks, or any JS logic that drives GSAP animations.
Quick Start
Create a reusable clamp function using gsap.utils.clamp(0, 100) and apply it to a scroll progress value.