
Gsap Utils
Map scroll, mouse, or numeric inputs into animation values with GSAP’s official `gsap.utils` helpers (clamp, mapRange, snap, wrap) without reinventing math.
Overview
gsap-utils is an agent skill for the Build phase that teaches correct use of GSAP `gsap.utils` math and collection helpers in animation code.
Install
npx skills add https://github.com/greensock/gsap-skills --skill gsap-utilsWhat is this skill?
- Documents clamp, mapRange, normalize, interpolate, random, snap, toArray, wrap, and pipe on `gsap.utils`
- Explains function form when the value argument is omitted (reusable mappers in handlers and tween callbacks)
- Covers `random()` nuance: pass `true` as last arg for a reusable function instead of omitting the value
- Pairs with gsap-core, gsap-timeline, gsap-scrolltrigger; easing extras live in gsap-plugins
- MIT-licensed official GSAP skill—no plugin registration required for utils
Adoption & trust: 19.3k installs on skills.sh; 8.5k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You are wiring scroll or input-driven GSAP tweens and keep rewriting clamp, map, and snap logic by hand.
Who is it for?
Solo builders using GSAP on marketing sites, dashboards, or creative landing pages who need reliable value mapping in timelines or ScrollTrigger.
Skip if: Teams not using GSAP or animations that are CSS-only with no programmatic value transforms.
When should I use this skill?
User asks about gsap.utils, clamp, mapRange, random, snap, toArray, wrap, or helper utilities in GSAP.
What do I get? / Deliverables
Your agent applies documented `gsap.utils` patterns—including function-form mappers—so animation values stay consistent and readable in vars and callbacks.
- Correct gsap.utils usage in animation or review snippets
- Function-form mapper patterns for repeated value transforms
Recommended Skills
Journey fit
How it compares
Official GSAP reference for utility methods—not a separate animation timeline or ScrollTrigger plugin skill.
Common Questions / FAQ
Who is gsap-utils for?
Frontend-focused solo builders and small teams who already use or plan to use GSAP and need authoritative guidance on `gsap.utils` in real animation code.
When should I use gsap-utils?
Use it during Build (frontend) when mapping scroll to progress, snapping draggable values, randomizing motion, or normalizing inputs inside GSAP tweens; combine with gsap-scrolltrigger when the util runs in scroll callbacks.
Is gsap-utils safe to install?
It is documentation-style procedural knowledge with MIT license; review the Security Audits panel on this Prism page before installing any skill from the registry.
SKILL.md
READMESKILL.md - Gsap Utils
# gsap.utils ## When to Use This Skill Apply when writing or reviewing code that uses **gsap.utils** for math, array/collection handling, unit parsing, or value mapping in animations (e.g. mapping scroll to a value, randomizing, snapping to a grid, or normalizing inputs). **Related skills:** Use with **gsap-core**, **gsap-timeline**, and **gsap-scrolltrigger** when building animations; CustomEase and other easing utilities are in **gsap-plugins**. ## Overview **gsap.utils** provides pure helpers; no need to register. Use in tween vars (e.g. function-based values), in ScrollTrigger or Observer callbacks, or in any JS that drives GSAP. All are on **gsap.utils** (e.g. `gsap.utils.clamp()`). **Omitting the value: function form.** Many utils accept the value to transform as the **last** argument. If you omit that argument, the util returns a **function** that accepts the value later. Use the function form when you need to clamp, map, normalize, or snap many values with the same config (e.g. in a mousemove handler or tween callback). **Exception: random()** — pass **true** as the last argument to get a reusable function (do not omit the value); see [random()](https://gsap.com/docs/v3/GSAP/UtilityMethods/random()). ```javascript // With value: returns the result gsap.utils.clamp(0, 100, 150); // 100 // Without value: returns a function you call with the value later let c = gsap.utils.clamp(0, 100); c(150); // 100 c(-10); // 0 ``` ## Clamping and Ranges ### clamp(min, max, value?) Constrains a value between min and max. Omit **value** to get a function: `clamp(min, max)(value)`. ```javascript gsap.utils.clamp(0, 100, 150); // 100 gsap.utils.clamp(0, 100, -10); // 0 let clampFn = gsap.utils.clamp(0, 100); clampFn(150); // 100 ``` ### mapRange(inMin, inMax, outMin, outMax, value?) Maps a value from one range to another. Use when converting scroll position, progress (0–1), or input range to an animation range. Omit **value** to get a function: `mapRange(inMin, inMax, outMin, outMax)(value)`. ```javascript gsap.utils.mapRange(0, 100, 0, 500, 50); // 250 gsap.utils.mapRange(0, 1, 0, 360, 0.5); // 180 (progress to degrees) let mapFn = gsap.utils.mapRange(0, 100, 0, 500); mapFn(50); // 250 ``` ### normalize(min, max, value?) Returns a value normalized to 0–1 for the given range. Inverse of mapping when the target range is 0–1. Omit **value** to get a function: `normalize(min, max)(value)`. ```javascript gsap.utils.normalize(0, 100, 50); // 0.5 gsap.utils.normalize(100, 300, 200); // 0.5 let normFn = gsap.utils.normalize(0, 100); normFn(50); // 0.5 ``` ### interpolate(start, end, progress?) Interpolates between two values at a given progress (0–1). Handles numbers, colors, and objects with matching keys. Omit **progress** to get a function: `interpolate(start, end)(progress)`. ```javascript gsap.utils.interpolate(0, 100, 0.5); // 50 gsap.utils.interpolate("#ff0000", "#0000ff", 0.5); // mid color gsap.utils.interpolate({ x: 0, y: 0 }, { x: 100, y: 50 }, 0.5); // { x: 50, y: 25 } let lerp = gsap.utils.interpolate(0, 100); lerp(0.5); // 50 ``` ## Random and Snap ### random(minimum, maximum[, snapIncrement, returnFunction]) / random(array[, returnFunction]) Returns a random number in the range **minimum**–**maximum**, or a random element from an **array**. Optional **snapIncrement** snaps the result to the nearest multiple (e.g. `5` → multiples of 5). **To get a reusable function**, pass **true** as the last argument (**returnFunction**); the returned function takes no args and returns a new random value each time. This is the only util that uses `true` for the function form instead of omitting the value. ```javascript // immedi