GSAP 원본
MotionPath Waypoints
스크롤 · MIT (public Pen panels); GSAP Standard No Charge License
갤러리 안에서는 화면을 벗어나거나 움직임을 멈추면 예제도 닫힙니다. 다시 재생할 때는 처음부터 시작해요.
저장한 HTML에서는 갤러리의 재생 설정이 적용되지 않아요.
SOURCE FILES
원본 코드 읽기
수집한 원본 소스와 실행 안내를 함께 제공합니다. 실행 HTML에는 미리보기를 위한 실행 환경이 들어 있습니다.
vendor/gsap-previews/sources/gsap-9cc9dd7ef20c/index.html
<div class="spacer">scroll down</div>
<div class="main">
<div class="container initial">
<div class="box"></div>
</div>
<div class="container second">
<div class="marker"></div>
</div>
<div class="container third">
<div class="marker"></div>
</div>
<div class="container fourth">
<div class="marker"></div>
</div>
<div class="container fifth">
<div class="marker"></div>
</div>
<div class="container sixth">
<div class="marker"></div>
</div>
</div>
<div class="spacer final"></div>vendor/gsap-previews/sources/gsap-9cc9dd7ef20c/style.css
body {
background-image: linear-gradient(
rgba(255, 255, 255, 0.05) 2px,
transparent 2px
),
linear-gradient(90deg, rgba(255, 255, 255, 0.05) 2px, transparent 2px),
linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
background-position: -2px -2px, -2px -2px, -1px -1px, -1px -1px;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.spacer {
height: 20vh;
display: flex;
justify-content: center;
align-items: center;
}
.main {
position: relative;
height: 300vh;
}
.container {
position: absolute;
width: 140px;
height: 140px;
border: 2px dashed var(--color-surface50);
border-radius: 10px;
display: flex;
justify-content: center;
align-items: center;
}
/* Start point */
.initial {
left: 60%;
top: 5%;
}
/* Down-the-page markers */
.second {
left: 10%;
top: 25%;
}
.third {
right: 10%;
top: 45%;
}
.fourth {
left: 20%;
top: 65%;
}
.fifth {
left: 60%;
top: 80%;
}
.sixth {
left: 15%;
top: 95%;
}
.marker {
width: 100px;
height: 100px;
border-radius: 10px;
}
.box {
width: 100px;
height: 100px;
z-index: 10;
border-radius: 10px;
background-image: url("https://assets.codepen.io/16327/flair-26.png");
background-size: contain;
background-repeat: no-repeat;
background-color: transparent;
}
함께 쓰는 파일 4개 보기
vendor/gsap-previews/sources/gsap-9cc9dd7ef20c/script.js
console.clear();
gsap.registerPlugin(ScrollTrigger, MotionPathPlugin);
let ctx;
function createTimeline() {
ctx && ctx.revert();
ctx = gsap.context(() => {
const box = document.querySelector(".box");
const boxStartRect = box.getBoundingClientRect();
// All containers except the first
const containers = gsap.utils.toArray(".container:not(.initial)");
// grab the points to animate between
const points = containers.map((container) => {
const marker = container.querySelector(".marker") || container;
const r = marker.getBoundingClientRect();
return {
x: r.left + r.width / 2 - (boxStartRect.left + boxStartRect.width / 2),
y: r.top + r.height / 2 - (boxStartRect.top + boxStartRect.height / 2)
};
});
const tl = gsap.timeline({
scrollTrigger: {
trigger: ".container.initial",
start: "clamp(top center)",
endTrigger: ".final",
end: "clamp(top center)",
scrub: 1
}
});
tl.to(".box", {
duration: 1,
ease: "none",
motionPath: {
path: points, // array like - [{x:100, y:50}, {x:200, y:0}, {x:300, y:100}]
curviness: 1.5 // adjust how curvy the path is, default is 1, 2 is more curvy
}
});
});
}
createTimeline();
window.addEventListener("resize", createTimeline);
vendor/gsap-previews/sources/gsap-9cc9dd7ef20c/adapters/host.css실행 안내·자료
/* StyleGallery host styles: independent replacement for unavailable shared Pen CSS. */
:root{--color-just-black:#111522;--color-surface-white:#f7f3ec;--color-surface75:#cfccc6;--color-surface50:#898e9f;--color-surface25:#414859;--color-shockingly-green:#95efd2;--color-lt-green:#b5f4da;--color-pink:#fbadce;--color-purple:#897dff;--color-lilac:#b5a1ff;--color-orangey:#ffd28c;--color-blue:#75d8ed;--color-ui-gradient:linear-gradient(135deg,#fbadce,#897dff);--light:#f7f3ec;--dark:#111522;--mid:#898e9f}
*{box-sizing:border-box}body{background:#111522;color:#f7f3ec;font-family:system-ui,sans-serif;margin:0;min-height:100vh;width:100%}button,input{font:inherit}button,.button{background:#111522;border:1px solid #898e9f;border-radius:.55rem;color:#f7f3ec;cursor:pointer;padding:.65rem 1rem}button:focus-visible,a:focus-visible,input:focus-visible{outline:3px solid #95efd2;outline-offset:4px}h1,h2,h3,h4{line-height:1.15}h4{font-weight:500}code{font-family:ui-monospace,monospace}.heading-l{font-size:clamp(2rem,6vw,5rem)}.heading-text{font-size:clamp(1.5rem,4vw,3rem)}.box{background:#95efd2;border-radius:14px;height:clamp(38px,12vw,80px);width:clamp(38px,12vw,80px)}.green{background:#95efd2}.purple{background:#897dff}.orange{background:#ffd28c}.gradient-pink{background:linear-gradient(140deg,#fbadce,#fc7f8e)}.gradient-purple{background:linear-gradient(140deg,#b5a1ff,#537ff7)}.center{align-items:center;display:flex;justify-content:center}.text-center{text-align:center}.panel{min-height:100vh;width:100%}.flair:not(img){background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNDgiIGhlaWdodD0iMjQ4IiB2aWV3Qm94PSIwIDAgMjQ4IDI0OCI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJnIiB4Mj0iMSIgeTI9IjEiPjxzdG9wIHN0b3AtY29sb3I9IiNiNWExZmYiLz48c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiM3NWQ4ZWQiLz48L2xpbmVhckdyYWRpZW50PjwvZGVmcz48ZyBmaWxsPSJ1cmwoI2cpIj48cGF0aCBkPSJNODcgMjBoNzR2NjdoNjd2NzRoLTY3djY3SDg3di02N0gyMFY4N2g2N1oiLz48L2c+PC9zdmc+");background-position:center;background-repeat:no-repeat;background-size:contain;height:80px;width:80px}.flair--3:not(img){background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNDgiIGhlaWdodD0iMjQ4IiB2aWV3Qm94PSIwIDAgMjQ4IDI0OCI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJnIiB4Mj0iMSIgeTI9IjEiPjxzdG9wIHN0b3AtY29sb3I9IiM5NWVmZDIiLz48c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiM1MzdmZjciLz48L2xpbmVhckdyYWRpZW50PjwvZGVmcz48ZyBmaWxsPSJ1cmwoI2cpIj48Y2lyY2xlIGN4PSIxMjQiIGN5PSIxMjQiIHI9Ijg4IiBmaWxsPSJub25lIiBzdHJva2U9InVybCgjZykiIHN0cm9rZS13aWR0aD0iNDgiLz48Y2lyY2xlIGN4PSIxODMiIGN5PSI2MCIgcj0iMjMiIGZpbGw9IiNmNmYzZWIiLz48L2c+PC9zdmc+")}.braces{font-size:1rem}img{max-width:100%}
/* External font programs are omitted; preserve readable fallback typography. */
body,button,input,h1,h2,h3,h4,p,span,div{font-family:inherit}body{font-family:system-ui,sans-serif}code,pre{font-family:ui-monospace,monospace}
vendor/gsap-previews/sources/gsap-9cc9dd7ef20c/adapters/script.js실행 안내·자료
window.__STYLEGALLERY_ASSETS__={};
console.clear();
gsap.registerPlugin(ScrollTrigger, MotionPathPlugin);
let ctx;
function createTimeline() {
ctx && ctx.revert();
ctx = gsap.context(() => {
const box = document.querySelector(".box");
const boxStartRect = box.getBoundingClientRect();
const containers = gsap.utils.toArray(".container:not(.initial)");
const points = containers.map((container) => {
const marker = container.querySelector(".marker") || container;
const r = marker.getBoundingClientRect();
return {
x: r.left + r.width / 2 - (boxStartRect.left + boxStartRect.width / 2),
y: r.top + r.height / 2 - (boxStartRect.top + boxStartRect.height / 2)
};
});
const tl = gsap.timeline({
scrollTrigger: {
trigger: ".container.initial",
start: "clamp(top center)",
endTrigger: ".final",
end: "clamp(top center)",
scrub: 1
}
});
tl.to(".box", {
duration: 1,
ease: "none",
motionPath: {
path: points,
// array like - [{x:100, y:50}, {x:200, y:0}, {x:300, y:100}]
curviness: 1.5
// adjust how curvy the path is, default is 1, 2 is more curvy
}
});
});
}
createTimeline();
window.addEventListener("resize", createTimeline);
LICENSE실행 안내·자료
<!--
Copyright (c) 2025 - GreenSock - https://codepen.io/GreenSock/pen/raerLaK
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.
-->
GSAP 3.15.0
Copyright 2026, GreenSock. All rights reserved.
Subject to the Standard No Charge License: https://gsap.com/standard-license.
The full notice in each original GSAP library file is preserved.
StyleGallery host adapter and replacement SVG subjects: locally authored.
BEHIND THE EXAMPLE
이 장면을 만드는 원리
다시 측정하는 경로와 컨텍스트
레이아웃 변경 뒤에는 경로 기하를 갱신하고 이전 표현을 정리해야 합니다.
- 이 예제에서는
- createTimeline은 이전 ctx를 revert하고 시작 box와 다섯 marker의 중심 차이를 points로 만듭니다. MotionPath의 curviness:1.5와 scrub:1이 그 점들을 연결합니다. resize가 같은 함수를 부르므로 이전 transform에서 누적 측정하지 않도록 정리 순서가 중요합니다.
