gsap-utils

Applies GSAP utility functions for clamping, mapping, snapping, and randomizing animation values.

Updated May 23, 2026
One-click install
npx skills add https://github.com/Oatse/CWE-Automation --skill gsap-utils-oatse
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gsap-utils
Source: https://github.com/Oatse/CWE-Automation/tree/main/.agents/skills/gsap-utils
Command: npx skills add https://github.com/Oatse/CWE-Automation --skill gsap-utils-oatse

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires gsap.

What problem does it solve? Writing animation logic often requires repetitive math for clamping values, mapping ranges, snapping to grids, and generating random values. This Skill provides correct usage patterns for the gsap.utils helper methods so these transforms are applied properly in tweens, ScrollTrigger callbacks, and event handlers. ## Core Features & Use Cases - Range and Math Helpers: Covers clamp, mapRange, normalize, interpolate, wrap, and wrapYoyo for converting and constraining numeric values, including the reusable function form when the value argument is omitted. - Randomization and Distribution: Documents random, snap, shuffle, and distribute for randomized tween values, grid snapping, and staggered value assignment across element collections. - Collections and Parsing: Explains toArray, selector, pipe, getUnit, unitize, and splitColor for scoping selectors, composing transforms, and handling units or colors. - Use Case: When building a scroll-driven animation, use mapRange to convert scroll progress into a rotation angle, snap to lock values to a grid, and random to vary tween targets per element. ## Quick Start Show me how to use gsap.utils.mapRange and clamp to convert scroll progress into a rotation value for my tween.

Frequently Asked Questions about gsap-utils

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I map a value from one range to another in GSAP?

Use gsap.utils.mapRange(inMin, inMax, outMin, outMax, value) to convert a value between ranges, such as mapping scroll progress 0-1 to 0-360 degrees. Omit the value argument to get a reusable function you can call repeatedly with the same configuration.

How do I get a random value in a GSAP tween?

Use gsap.utils.random(min, max) for a number in a range, or pass an array to pick a random element. In tween vars you can use the string form like "random(-100, 100, 5)" and GSAP evaluates it per target.

Does gsap.utils.clamp return a function or a value?

clamp returns a value when you pass all three arguments: clamp(min, max, value). If you omit the value argument, it returns a reusable function that accepts the value later, which is useful in mousemove handlers or tween callbacks.

How do I scope GSAP selectors to a component or ref?

Use gsap.utils.selector(scope) with a DOM element or React ref to get a scoped selector function. The returned function finds elements only within that container, so selectors like ".box" match descendants of the component rather than the whole document.

Why does gsap.utils.random not return a function when I omit arguments?

random is the exception to the omit-the-value pattern used by other utils. To get a reusable function, pass true as the last argument, for example gsap.utils.random(-200, 500, 10, true), and the returned function produces a new random value on each call.

Can gsap.utils.mapRange handle values with units like px or percent?

No, mapRange and normalize work on plain numbers only and do not parse units. Use gsap.utils.getUnit to read a unit string and gsap.utils.unitize to append a unit when building CSS or tween values.