gsap-utils

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

1|Updated Aug 20, 2023
One-click install
npx skills add https://github.com/imanlangaran/mini-projects --skill gsap-utils-imanlangaran
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gsap-utils
Source: https://github.com/imanlangaran/mini-projects/tree/main/building-sell/.claude/skills/gsap-utils
Command: npx skills add https://github.com/imanlangaran/mini-projects --skill gsap-utils-imanlangaran

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 animation code handles these transformations without manual math errors. ## Core Features & Use Cases - Range and Math Helpers: Covers clamp, mapRange, normalize, interpolate, wrap, and wrapYoyo for transforming values between ranges. - Randomization and Snapping: Explains random with snap increments, snap to multiples or arrays, shuffle, and distribute for staggered values across targets. - Unit and Collection Utilities: Documents getUnit, unitize, splitColor, selector, toArray, and pipe for parsing values and composing transforms. - Use Case: When building a scroll-driven animation, use mapRange to convert scroll progress into rotation degrees, then snap the result to 15-degree increments for a stepped dial effect. ## Quick Start Show me how to use gsap.utils.mapRange and snap to convert scroll progress into a snapped rotation value for my element.

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 rotation 0-360. Omit the value argument to get a reusable function for repeated conversions.

How to get a random number in a GSAP tween?

Use gsap.utils.random(min, max, snapIncrement) for an immediate value, or pass true as the last argument to get a reusable function. In tween vars, 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 function you can call later with any value, which is useful in scroll handlers and tween callbacks.

Can I snap GSAP values to a grid or specific increments?

Yes, use gsap.utils.snap(snapTo, value) to round to the nearest multiple or nearest value in an array. In tweens, use the snap property like { x: 200, snap: { x: 20 } } for grid-aligned animation.

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. Selectors like q(".box") then only match descendants of that container, not the whole document.

What are the limitations of gsap.utils.mapRange with units?

mapRange and normalize operate only on numbers and do not handle units like px or %. Use gsap.utils.getUnit to read a unit and gsap.utils.unitize to append one when unit-aware conversion is needed.