본문으로 건너뛰기
Skillpedia
일반 코딩101k · #1186

gsap-utils

하는 일

이 도구 모음은 애니메이션을 위한 계산과 데이터 정리를 돕습니다. 값을 제한하고, 한 값을 다른 값에 대응시키고, 숫자를 정규화하고, 색이나 값을 섞고, 난수를 생성하고, 목록의 항목을 배열할 수 있습니다.

사용하는 경우

  • ✓값이 특정 범위 안에 머물러야 할 때.
  • ✓스크롤 위치를 애니메이션 움직임으로 바꿀 때.
  • ✓임의의 값을 만들거나 항목을 무작위 순서로 배열하고 싶을 때.

스킬 링크

https://github.com/nexu-io/open-design/blob/main/skills/gsap-utils/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/nexu-io/open-design/blob/main/skills/gsap-utils/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“객체의 X 위치가 100픽셀을 넘지 않도록 하려면 어떻게 하나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

이 함수들은 계산기와 정리 도구처럼 작동합니다. 등록할 필요 없이 gsap.utils로 바로 사용할 수 있습니다. 일부는 같은 설정을 여러 번 재사용할 수 있도록 함수를 반환하기도 합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

gsap.utils

Curated from GreenSock's official GSAP skills: https://github.com/greensock/gsap-skills

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().

// 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).

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).

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).

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).

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.

// immediate value: number in range
gsap.utils.random(-100, 100);        // e.g. 42.7
gsap.utils.random(0, 500, 5);        // 0–500, snapped to nearest 5

// reusable function: pass true as last argument
let randomFn = gsap.utils.random(-200, 500, 10, true);
randomFn();  // random value in range, snapped to 10
randomFn();  // another random value

// array: pick one value at random
gsap.utils.random(["red", "blue", "green"]);  // "red", "blue", or "green"
let randomFromArray = gsap.utils.random([0, 100, 200], true);
randomFromArray();  // 0, 100, or 200

…

자주 묻는 질문

‘값을 생략한다(omitting the value)’는 무슨 뜻인가요?

함수에 마지막 데이터를 주지 않는다는 뜻입니다. 즉시 결과를 받는 대신, 나중에 빠진 데이터와 함께 호출할 수 있는 새 함수를 받습니다. 같은 규칙을 여러 값에 적용할 때 유용합니다.

‘clamp’와 ‘mapRange’의 차이는 무엇인가요?

‘clamp’는 값이 최소값과 최대값을 넘지 않도록 막기만 합니다. ‘mapRange’는 값을 완전히 다른 눈금으로 바꿉니다.

‘random’으로 색을 고르려면 어떻게 하나요?

‘random’ 함수에 색의 배열을 넘기면 됩니다. 예를 들어 gsap.utils.random(['red', 'blue', 'green'])처럼 쓰며, 호출할 때마다 무작위 색을 고릅니다.

상세 정보

작성자의 원본 설명

Official GSAP skill for gsap.utils — clamp, mapRange, normalize, interpolate, random, snap, toArray, wrap, pipe. Use when the user asks about gsap.utils, clamp, mapRange, random, snap, toArray, wrap, or helper utilities in GSAP.

repo: nexu-io/open-design

인기도

GitHub 스타
101k
순위
#1186
라이선스
Apache-2.0
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬