GSAP 사례 연구
Animation Control
데이터 · MIT (local companion); GSAP Standard No Charge License (runtime)
갤러리 안에서는 화면을 벗어나거나 움직임을 멈추면 예제도 닫힙니다. 다시 재생할 때는 처음부터 시작해요.
저장한 HTML에서는 갤러리의 재생 설정이 적용되지 않아요.
SOURCE FILES
독립 예제 코드 읽기
사례의 구도나 문서의 원리를 바탕으로 새로 만든 예제입니다. 아래 코드를 복사해 직접 응용할 수 있습니다. 실행 HTML에는 미리보기를 위한 실행 환경이 들어 있습니다.
vendor/gsap-previews/sources/gsap-e92b443c7ee1/source-input.js
// store the tween or timeline in a variable
let tween = gsap.to("#logo", {duration: 1, x: 100});
//pause
tween.pause();
//resume (honors direction - reversed or not)
tween.resume();
//reverse (always goes back towards the beginning)
tween.reverse();
//jump to exactly 0.5 seconds into the tween
tween.seek(0.5);
//jump to exacty 1/4th into the tween 's progress:
tween.progress(0.25);
//make the tween go half-speed
tween.timeScale(0.5);
//make the tween go double-speed
tween.timeScale(2);
//immediately kill the tween and make it eligible for garbage collection
tween.kill();
// You can even chain control methods
// Play the timeline at double speed - in reverse.
tween.timeScale(2).reverse();vendor/gsap-previews/sources/gsap-e92b443c7ee1/index.html실행 안내·자료
<main class="study"><p class="study-label">공식 문서 기반 · 독립 예제</p><header><h2>한 효과를 다르게 제어하기</h2><p>진행 위치, 재생 방향, 속도와 효과 제거를 별도 입력으로 비교합니다.</p></header><div class="stage"><div class="track"><div id="logo"><svg viewBox="0 0 160 160" role="img" aria-label="움직이는 도형"><defs><linearGradient id="orb-g" x2="1" y2="1"><stop stop-color="#94efd2"/><stop offset="1" stop-color="#8980ff"/></linearGradient></defs><path d="m80 8 22 44 49 7-35 34 8 49-44-23-44 23 8-49L9 59l49-7Z" fill="url(#orb-g)"/></svg></div><span class="endpoint">100px</span></div></div><div class="controls"><button id="resume" type="button">재생</button><button id="pause" type="button">정지</button><button id="reverse" type="button">역재생</button><button id="seek" type="button">0.5초로</button><button id="progress" type="button">25%로</button><button id="slow" type="button">0.5배속</button><button id="fast" type="button">2배속</button><button id="fast-reverse" type="button">2배속 역재생</button><button id="kill" type="button">효과 제거</button><button id="recreate" type="button">새로 만들기</button></div><p id="control-reading" class="readout" aria-live="polite">준비됨</p></main>함께 쓰는 파일 3개 보기
vendor/gsap-previews/sources/gsap-e92b443c7ee1/style.css실행 안내·자료
*{box-sizing:border-box}body{background:#111522;color:#f5f2eb;font-family:system-ui,sans-serif;margin:0}button{font:inherit}.study{margin:0 auto;max-width:1100px;min-height:100vh;padding:clamp(20px,4vw,42px)}.study-label{color:#95efd2;font-size:12px;letter-spacing:.08em;margin:0 0 24px}header h2{font-size:clamp(24px,4vw,40px);letter-spacing:-.04em;margin:0 0 12px}header p{color:#aeb7c9;line-height:1.6;margin:0 0 24px;max-width:62ch}.controls{display:flex;flex-wrap:wrap;gap:8px;margin:20px 0}button{background:#26314b;border:1px solid #617394;border-radius:9px;color:#f5f2eb;cursor:pointer;padding:9px 14px}button:hover{background:#334261}button:focus-visible{outline:3px solid #95efd2;outline-offset:3px}button:disabled{cursor:default;opacity:.45}.stage{align-items:center;background:radial-gradient(ellipse at top,#243253,#141c2d);border:1px solid #3d4c68;border-radius:20px;display:flex;justify-content:center;min-height:220px;overflow:hidden;position:relative}.note{color:#aeb7c9;font-size:13px;line-height:1.5}.readout{color:#95efd2;font-family:ui-monospace,monospace;font-size:13px;min-height:2em}.stage svg{display:block;max-width:100%}code{font-family:ui-monospace,monospace}button[aria-pressed="true"]{background:#95efd2;color:#111522}
.track{height:100px;position:relative;width:220px}#logo{height:100px;left:0;position:absolute;top:0;width:100px}.endpoint{border-right:1px dashed #a8b9d6;color:#a8b9d6;font-size:12px;height:100%;padding-right:10px;position:absolute;right:0;top:0}vendor/gsap-previews/sources/gsap-e92b443c7ee1/script.js실행 안내·자료
gsap.registerPlugin();
let tween;let killed=false;const reading=document.getElementById('control-reading');
function report(action){reading.textContent=action+' · '+Math.round(tween.progress()*100)+'% · '+tween.timeScale()+'배속'}
function recreate(){tween?.kill();gsap.set('#logo',{x:0});killed=false;tween=gsap.to('#logo',{duration:1,x:100,paused:true});report('새 효과')}
const actions={resume:()=>tween.resume(),pause:()=>tween.pause(),reverse:()=>tween.reverse(),seek:()=>tween.seek(0.5),progress:()=>tween.progress(0.25),slow:()=>tween.timeScale(0.5),fast:()=>tween.timeScale(2),'fast-reverse':()=>tween.timeScale(2).reverse(),kill:()=>{tween.kill();killed=true}};
for(const [id,action] of Object.entries(actions))document.getElementById(id).addEventListener('click',()=>{if(killed){reading.textContent='효과가 제거되었습니다. 새로 만들기를 누르세요.';return}action();report(document.getElementById(id).textContent)});
document.getElementById('recreate').addEventListener('click',recreate);recreate();LICENSE실행 안내·자료
Locally authored companion HTML/CSS/control wiring: MIT License.
Copyright (c) 2026 StyleGallery contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The separately retained official documentation excerpt is source input, not a recovered CodePen source set; this local MIT notice does not assign a new license to that excerpt.
GSAP 3.15.0: Copyright 2026, GreenSock. All rights reserved. Subject to https://gsap.com/standard-license. Original library notices are preserved.
BEHIND THE EXAMPLE
이 장면을 만드는 원리
재생 위치와 효과 생명주기의 차이
정지, 재개, 역재생과 제거는 서로 다른 동작으로 취급합니다.
- 이 예제에서는
- 문서의 pause·resume·reverse·seek·progress·timeScale·kill을 각각의 버튼에 연결했습니다. 동반 예제는 처음에 paused 트윈을 만들고 kill 후에는 같은 제어 명령을 막으며 새로 만들기로 다시 생성합니다. 문서의 여러 호출을 동시에 실행해 마지막 결과만 보여 주는 방식은 아닙니다.
코드와 함께 확인하기
코드에서 찾기
tween.kill()source-input.js문서의 효과 제거 호출입니다.
function recreatescript.js동반 예제는 제거된 효과 대신 새 트윈을 만들며 처음부터 이동합니다.
const actions=script.js각 문서 호출을 독립 제어 입력으로 제공합니다.
직접 해보기
정지 후 0.5초와 25% 버튼을 누릅니다.
살펴볼 변화1초 트윈의 서로 다른 진행 위치로 이동하는지 확인합니다.
효과 제거 후 재생을 누르고 새로 만들기를 누릅니다.
살펴볼 변화제거된 효과와 새 효과를 구분하고 복원은 명시적 재생성으로 이루어져야 합니다.
