gsap-utils

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

Updated Jun 17, 2026
One-click install
npx skills add https://github.com/KKChen666/TongXiao --skill gsap-utils-kkchen666
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gsap-utils
Source: https://github.com/KKChen666/TongXiao/tree/main/.opencode/skills/gsap-utils
Command: npx skills add https://github.com/KKChen666/TongXiao --skill gsap-utils-kkchen666

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires gsap.

What problem does it solve? Writing animation code often requires repetitive math for value mapping, clamping, snapping to grids, and randomization. This Skill provides authoritative guidance on the gsap.utils API so generated animation code uses the correct utility signatures and function-form patterns. ## Core Features & Use Cases - Range Math: Covers clamp, mapRange, normalize, and interpolate for converting scroll positions, progress values, and inputs into animation ranges. - Randomization and Snapping: Documents random (including the reusable function form via the true argument), snap, shuffle, and distribute for grid-based and staggered animations. - Collections and Units: Explains toArray, selector, pipe, wrap, wrapYoyo, getUnit, unitize, and splitColor for DOM scoping, unit handling, and color manipulation. - Use Case: When building a scroll-driven animation, use mapRange to convert scroll progress to a rotation angle, snap to align movement to a grid, and selector to scope queries inside a React component ref. ## Quick Start Ask the assistant to write a GSAP animation that maps scroll progress to element rotation using gsap.utils.mapRange and snaps positions to a 20-pixel grid.

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 scroll progress value to an animation range in GSAP?

Use gsap.utils.mapRange(inMin, inMax, outMin, outMax, value) to convert a value from one range to another, such as mapping 0-1 progress to 0-360 degrees. Omit the value argument to get a reusable function for repeated conversions.

How do I get a reusable random function with gsap.utils.random?

Pass true as the last argument to gsap.utils.random, for example gsap.utils.random(-200, 500, 10, true), to receive a function that returns a new random value on each call. Unlike other utils, random does not use the omit-the-value pattern.

Does gsap.utils.mapRange handle CSS units like px or percent?

No, mapRange and normalize operate on plain numbers only. Use gsap.utils.getUnit to read a unit string and gsap.utils.unitize to append a unit when building CSS values.

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

Use gsap.utils.selector(scope) with a DOM element or React ref to create a scoped selector function. Queries like q(".box") then match only descendants of that component instead of the whole document.

What is the difference between gsap.utils.wrap and wrapYoyo?

wrap cycles a value back into the min-max range when it exceeds the bounds, useful for infinite loops. wrapYoyo bounces the value back at the range ends, producing back-and-forth oscillation instead of a cycle.