GSAP 원본
Infinite looped scrolling sections
스크롤 · MIT (public Pen panels); GSAP Standard No Charge License
갤러리 안에서는 화면을 벗어나거나 움직임을 멈추면 예제도 닫힙니다. 다시 재생할 때는 처음부터 시작해요.
저장한 HTML에서는 갤러리의 재생 설정이 적용되지 않아요.
SOURCE FILES
원본 코드 읽기
수집한 원본 소스와 실행 안내를 함께 제공합니다. 실행 HTML에는 미리보기를 위한 실행 환경이 들어 있습니다.
vendor/gsap-previews/sources/gsap-d8b7b6f30ed2/index.html
<section class="first panel description">
<h1>Looped "Scrolling"</br> Section Transitions</h1>
<div class="scroll-down">Scroll up or down<div class="arrow"></div></div>
</section>
<section class="panel green">
<h2 class="panel__number">1</p>
</section>
<section class="panel blue">
<h2 class="panel__number">2</p>
</section>
<section class="panel purple">
<h2 class="panel__number">3</h2>
</section>
<section class="panel orange">
<h2 class="panel__number">4</p>
</section>vendor/gsap-previews/sources/gsap-d8b7b6f30ed2/style.css
html, body {
height: 100%;
}
.panel {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
text-align: center
}
section:not(.first) {
opacity: 0;
visibility: hidden;
transform: scale(0.8);
}
.panel p {
font-size: 5vw;
}함께 쓰는 파일 4개 보기
vendor/gsap-previews/sources/gsap-d8b7b6f30ed2/script.js
let sections = gsap.utils.toArray("section"),
currentSection = sections[0];
gsap.defaults({overwrite: 'auto', duration: 0.3});
// stretch out the body height according to however many sections there are.
gsap.set("body", {height: (sections.length * 100) + "%"});
// create a ScrollTrigger for each section
sections.forEach((section, i) => {
ScrollTrigger.create({
// use dynamic scroll positions based on the window height (offset by half to make it feel natural)
start: () => (i - 0.5) * innerHeight,
end: () => (i + 0.5) * innerHeight,
// when a new section activates (from either direction), set the section accordinglyl.
onToggle: self => self.isActive && setSection(section)
});
});
function setSection(newSection) {
if (newSection !== currentSection) {
gsap.to(currentSection, {scale: 0.8, autoAlpha: 0})
gsap.to(newSection, {scale: 1, autoAlpha: 1});
currentSection = newSection;
}
}
// handles the infinite part, wrapping around at either end....
ScrollTrigger.create({
start: 1,
end: () => ScrollTrigger.maxScroll(window) - 1,
onLeaveBack: self => self.scroll(ScrollTrigger.maxScroll(window) - 2),
onLeave: self => self.scroll(2)
}).scroll(2);vendor/gsap-previews/sources/gsap-d8b7b6f30ed2/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}
/* Locally authored presentation for panels whose shared stylesheet was not acquired. */
.panel{align-items:center;display:flex;flex-direction:column;justify-content:center;padding:2rem;text-align:center}.panel__number{font-size:clamp(6rem,25vw,16rem);font-weight:700}.blue{background:#537ff7}.panel h1{font-size:clamp(2rem,6vw,4rem)}vendor/gsap-previews/sources/gsap-d8b7b6f30ed2/adapters/script.js실행 안내·자료
window.__STYLEGALLERY_ASSETS__={};
let sections = gsap.utils.toArray("section"), currentSection = sections[0];
gsap.defaults({ overwrite: "auto", duration: 0.3 });
gsap.set("body", { height: sections.length * 100 + "%" });
sections.forEach((section, i) => {
ScrollTrigger.create({
// use dynamic scroll positions based on the window height (offset by half to make it feel natural)
start: () => (i - 0.5) * innerHeight,
end: () => (i + 0.5) * innerHeight,
// when a new section activates (from either direction), set the section accordinglyl.
onToggle: (self) => self.isActive && setSection(section)
});
});
function setSection(newSection) {
if (newSection !== currentSection) {
gsap.to(currentSection, { scale: 0.8, autoAlpha: 0 });
gsap.to(newSection, { scale: 1, autoAlpha: 1 });
currentSection = newSection;
}
}
ScrollTrigger.create({
start: 1,
end: () => ScrollTrigger.maxScroll(window) - 1,
onLeaveBack: (self) => self.scroll(ScrollTrigger.maxScroll(window) - 2),
onLeave: (self) => self.scroll(2)
}).scroll(2);
LICENSE실행 안내·자료
<!--
Copyright (c) 2020 - GreenSock - https://codepen.io/GreenSock/pen/rNOebyo
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
이 장면을 만드는 원리
활성 섹션과 진행 중 등장 표현
현재 활성 상태와 그 상태를 드러내는 시간 기반 전환을 구분합니다.
- 이 예제에서는
- 각 구간의 onToggle이 setSection을 호출해 이전 섹션을 0.8배·투명으로, 새 섹션을 1배·불투명으로 바꿉니다. defaults.overwrite:auto와 currentSection이 최신 대상으로 전환을 이어갑니다. 구간 진입 후 0.3초 동안 움직이는 효과이며 스크롤 거리에 직접 연결된 scrub은 아닙니다.
