What problem does it solve?
GSAP.utils provides a set of pure helpers for numerical math, range mapping, color parsing, and array handling inside GSAP-driven animations, helping developers avoid manual implementations.
Core Features & Use Cases
- clamp(min, max, value) constrains a value within a min/max range for tween values.
- mapRange(inMin, inMax, outMin, outMax, value) maps a value from one scale to another, useful for scroll or progress-based animations.
- normalize(min, max, value) returns a 0–1 ratio for a value within a range.
- interpolate(start, end, progress) blends numbers, colors, or objects based on progress.
- random and snap simplify randomness and grid-aligned values for tweens.
- toArray(...) and selector utilities help convert selectors to arrays and scope them to containers.
- wrap and wrapYoyo create looping or bidirectional ranges for cyclic animations.
Quick Start
Call gsap.utils.clamp(0, 1, value) to constrain a value within a range during an animation.