GSAP 원본
Trigger On Scroll
스크롤 · MIT (public Pen panels); GSAP Standard No Charge License
갤러리 안에서는 화면을 벗어나거나 움직임을 멈추면 예제도 닫힙니다. 다시 재생할 때는 처음부터 시작해요.
저장한 HTML에서는 갤러리의 재생 설정이 적용되지 않아요.
SOURCE FILES
원본 코드 읽기
수집한 원본 소스와 실행 안내를 함께 제공합니다. 실행 HTML에는 미리보기를 위한 실행 환경이 들어 있습니다.
vendor/gsap-previews/sources/gsap-7f98c7f63962/index.html
<main>
<div id="trigger-container">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 186 62">
<rect fill="url(#grad-1)" width="186" height="62" rx="31" />
<rect id="knob" fill="url(#grad-2)" width="93" height="62" rx="31" />
<defs>
<linearGradient id="grad-1" x1="47" y1="-80" x2="0" y2="99" gradientUnits="userSpaceOnUse">
<stop offset="0.3" stop-color="#FEC5FB"></stop>
<stop offset="1" stop-color="#00BAE2"></stop>
</linearGradient>
<linearGradient id="grad-2" x1="17" y1="30" x2="42" y2="80" gradientUnits="userSpaceOnUse">
<stop offset="0.2" stop-color="#FEC5FB"></stop>
<stop offset="1" stop-color="#00BAE2"></stop>
</linearGradient>
</defs>
</svg>
</div>
</main>
<div class="info">
<h1><span id="text">Scroll down</span></h1>
<svg id="arrow" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 11" aria-hidden="true">
<path fill="#fffce1" d="M4.055 0v7.71l-3-3L0 5.79l4.805 4.804 4.804-4.805-1.054-1.078-3 3V0h-1.5Z"></path>
</svg>
</div>vendor/gsap-previews/sources/gsap-7f98c7f63962/style.css
@font-face {
font-display: block;
font-family: Mori;
font-style: normal;
font-weight: 600;
src: url(https://assets.codepen.io/16327/PPMori-Regular.woff) format("woff");
}
html,
body {
margin: 0;
padding: 0;
width: 100%;
height: 200vh;
font-family: "Mori";
color: #fffce1;
background: #0e100f;
}
main {
width: 100%;
height: 200vh;
display: flex;
align-items: center;
justify-content: center;
}
#trigger-container {
position: relative;
display: block;
width: 50%;
max-width: 500px;
border-top: dashed 2px grey;
border-bottom: dashed 2px grey;
padding: 4rem;
}
.info {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
width: 300px;
background-color: #191919;
border-radius: 10px;
gap: 1rem;
}
.info h1 {
font-size: 1.2rem;
text-align: center;
}
.info svg {
height: 20px;
}
.gsap-marker-end, .gsap-marker-scroller-end {
font-family: "Mori"!important;
color: #fa7777 !important;
border-color: #fa7777 !important;
}
.gsap-marker-start, .gsap-marker-scroller-start {
font-family: "Mori"!important;
color: #abff84 !important;
border-color: #abff84 !important;
}함께 쓰는 파일 4개 보기
vendor/gsap-previews/sources/gsap-7f98c7f63962/script.js
gsap
.timeline({
paused: true,
scrollTrigger: {
markers: true,
trigger: "#trigger-container",
start: "0 60%",
end: "100% 40%",
toggleActions: "play reverse play reverse", //onEnter, onLeave, onEnterBack, onLeaveBack
onEnter: () => text.innerText = "onEnter",
onLeave: () => text.innerText = "onLeave",
onEnterBack: () => text.innerText = "onEnterBack",
onLeaveBack: () => text.innerText = "onLeaveBack"
}
})
.to("#knob", {
duration: 1,
x: 93,
ease: "expo.inOut"
});
// changing the text in the bar
let inZone = false
ScrollTrigger.create({
start: 0,
end: "max",
onUpdate: (self) => {
if (self.direction !== self.prevDirection && !inZone) {
gsap.to("#arrow", {
rotation: self.direction === 1 ? 0 : -180,
duration: 0.2,
});
self.prevDirection = self.direction;
}
}
});
vendor/gsap-previews/sources/gsap-7f98c7f63962/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);--color-ui-gradient-background:linear-gradient(135deg,#fbadce,#897dff);--color-text-gradient:linear-gradient(135deg,#fbadce,#897dff);--gradient-summer-fair:linear-gradient(135deg,#ffd28c,#fbadce);--gradient-lipstick:linear-gradient(135deg,#fbadce,#fc7f8e);--gradient-macha:linear-gradient(135deg,#b5f4da,#75d8ed);--color-grey:#898e9f;--color-grey-dark:#414859;--color-scroll-pink-lt:#fbadce;--color-text-purple:#b5a1ff;--surface50:#898e9f;--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}
body main{align-items:flex-start;padding-top:62vh}body #trigger-container{padding:20px;width:min(70vw,360px)}body .info{top:24px;transform:translateX(-50%);width:min(300px,90vw)}vendor/gsap-previews/sources/gsap-7f98c7f63962/adapters/script.js실행 안내·자료
window.__STYLEGALLERY_ASSETS__={};
gsap.timeline({
paused: true,
scrollTrigger: {
markers: true,
trigger: "#trigger-container",
start: "0 60%",
end: "100% 40%",
toggleActions: "play reverse play reverse",
//onEnter, onLeave, onEnterBack, onLeaveBack
onEnter: () => text.innerText = "onEnter",
onLeave: () => text.innerText = "onLeave",
onEnterBack: () => text.innerText = "onEnterBack",
onLeaveBack: () => text.innerText = "onLeaveBack"
}
}).to("#knob", {
duration: 1,
x: 93,
ease: "expo.inOut"
});
let inZone = false;
ScrollTrigger.create({
start: 0,
end: "max",
onUpdate: (self) => {
if (self.direction !== self.prevDirection && !inZone) {
gsap.to("#arrow", {
rotation: self.direction === 1 ? 0 : -180,
duration: 0.2
});
self.prevDirection = self.direction;
}
}
});
LICENSE실행 안내·자료
<!--
Copyright (c) 2024 - GreenSock - https://codepen.io/GreenSock/pen/xxoPrKX
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
이 장면을 만드는 원리
진입 이벤트와 연속 스크럽의 차이
진입이 효과를 시작하는 방식과 위치가 매 순간 진행률을 정하는 방식을 구분합니다.
- 이 예제에서는
- toggleActions는 onEnter·onLeave·onEnterBack·onLeaveBack에 play reverse play reverse를 대응합니다. 손잡이는 1초 트윈으로 93px 움직이며 scrub은 설정하지 않았습니다. 별도 ScrollTrigger는 방향을 읽어 화살표만 바꿉니다.
코드와 함께 확인하기
코드에서 찾기
toggleActions: "play reverse play reverse"script.js네 경계 이벤트에 재생 방향을 대응시킵니다.
.to("#knob",script.js경계 안에서 스크롤을 멈춰도 시간에 따라 진행하는 트윈입니다.
직접 해보기
아래로 두 경계를 넘고 위로 두 경계를 넘습니다.
살펴볼 변화onEnter·onLeave·onEnterBack·onLeaveBack 문구와 재생 방향을 확인합니다.
시작선을 넘은 직후 스크롤을 멈춥니다.
살펴볼 변화손잡이가 1초 효과를 계속 끝내므로 연속 스크럽으로 설명하면 안 됩니다.
