GSAP 원본
Swipe Slider
섹션 · MIT (public Pen panels); GSAP Standard No Charge License
갤러리 안에서는 화면을 벗어나거나 움직임을 멈추면 예제도 닫힙니다. 다시 재생할 때는 처음부터 시작해요.
저장한 HTML에서는 갤러리의 재생 설정이 적용되지 않아요.
SOURCE FILES
원본 코드 읽기
수집한 원본 소스와 실행 안내를 함께 제공합니다. 실행 HTML에는 미리보기를 위한 실행 환경이 들어 있습니다.
vendor/gsap-previews/sources/gsap-6d7d9d29c890/index.html
<!--
Sections animate in and out on scroll. Scroll up or down and the sections will wrap around after hitting the start or end. Uses GSAP for the animations.
-->
<header>
<div>Animated Sections</div>
<div><a href="https://codepen.io/BrianCross/pen/PoWapLP">Original Inspiration</a></div>
</header>
<section class="first">
<div class="outer">
<div class="inner">
<div class="bg one">
<h2 class="section-heading">Scroll down</h2>
</div>
</div>
</div>
</section>
<section class="second">
<div class="outer">
<div class="inner">
<div class="bg">
<h2 class="section-heading">Animated with GSAP</h2>
</div>
</div>
</div>
</section>
<section class="third">
<div class="outer">
<div class="inner">
<div class="bg">
<h2 class="section-heading">GreenSock</h2>
</div>
</div>
</div>
</section>
<section class="fourth">
<div class="outer">
<div class="inner">
<div class="bg">
<h2 class="section-heading">Animation platform</h2>
</div>
</div>
</div>
</section>
<section class="fifth">
<div class="outer">
<div class="inner">
<div class="bg">
<h2 class="section-heading">Keep scrolling</h2>
</div>
</div>
</div>
</section>vendor/gsap-previews/sources/gsap-6d7d9d29c890/style.css
$bg-gradient: linear-gradient(
180deg,
rgba(0, 0, 0, 0.6) 50%,
rgba(0, 0, 0, 0.1) 100%
);
* {
box-sizing: border-box;
user-select: none;
}
a {
color: var(--color-surface-white);
text-decoration: none;
}
body {
margin: 0;
padding: 0;
height: 100vh;
color: var(--light);
text-transform: uppercase;
}
h2 {
font-size: clamp(1rem, 6vw, 10rem);
font-weight: 600;
line-height: 1.2;
text-align: center;
margin-right: -0.5em;
width: 90vw;
max-width: 1200px;
text-transform: none;
}
header {
position: fixed;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 5%;
width: 100%;
z-index: 3;
height: 7em;
font-size: clamp(0.66rem, 2vw, 1rem);
letter-spacing: 0.5em;
}
section {
height: 100%;
width: 100%;
top: 0;
position: fixed;
visibility: hidden;
.outer,
.inner {
width: 100%;
height: 100%;
overflow-y: hidden;
}
.bg {
display: flex;
align-items: center;
justify-content: center;
position: absolute;
height: 100%;
width: 100%;
top: 0;
background-size: cover;
background-position: center;
h2 {
z-index: 999;
}
.clip-text {
overflow: hidden;
}
}
}
.first {
.bg {
background-image: $bg-gradient,
url("https://assets.codepen.io/16327/site-landscape-1.jpg");
}
}
.second {
.bg {
background-image: $bg-gradient,
url("https://assets.codepen.io/16327/site-landscape-2.jpg");
}
}
.third {
.bg {
background-image: $bg-gradient,
url("https://assets.codepen.io/16327/site-landscape-3.jpg");
}
}
.fourth {
.bg {
background-image: $bg-gradient,
url("https://assets.codepen.io/16327/site-landscape-4.jpg");
}
}
.fifth {
.bg {
background-image: $bg-gradient,
url("https://assets.codepen.io/16327/site-landscape-5.jpg");
background-position: 50% 45%;
}
}
h2 * {
will-change: transform;
}함께 쓰는 파일 4개 보기
vendor/gsap-previews/sources/gsap-6d7d9d29c890/script.js
gsap.registerPlugin(Observer);
let sections = document.querySelectorAll("section"),
images = document.querySelectorAll(".bg"),
headings = gsap.utils.toArray(".section-heading"),
outerWrappers = gsap.utils.toArray(".outer"),
innerWrappers = gsap.utils.toArray(".inner"),
splitHeadings = headings.map(heading => new SplitText(heading, { type: "chars,words,lines", linesClass: "clip-text" })),
currentIndex = -1,
wrap = gsap.utils.wrap(0, sections.length),
animating;
gsap.set(outerWrappers, { yPercent: 100 });
gsap.set(innerWrappers, { yPercent: -100 });
function gotoSection(index, direction) {
index = wrap(index); // make sure it's valid
animating = true;
let fromTop = direction === -1,
dFactor = fromTop ? -1 : 1,
tl = gsap.timeline({
defaults: { duration: 1.25, ease: "power1.inOut" },
onComplete: () => animating = false
});
if (currentIndex >= 0) {
// The first time this function runs, current is -1
gsap.set(sections[currentIndex], { zIndex: 0 });
tl.to(images[currentIndex], { yPercent: -15 * dFactor })
.set(sections[currentIndex], { autoAlpha: 0 });
}
gsap.set(sections[index], { autoAlpha: 1, zIndex: 1 });
tl.fromTo([outerWrappers[index], innerWrappers[index]], {
yPercent: i => i ? -100 * dFactor : 100 * dFactor
}, {
yPercent: 0
}, 0)
.fromTo(images[index], { yPercent: 15 * dFactor }, { yPercent: 0 }, 0)
.fromTo(splitHeadings[index].chars, {
autoAlpha: 0,
yPercent: 150 * dFactor
}, {
autoAlpha: 1,
yPercent: 0,
duration: 1,
ease: "power2",
stagger: {
each: 0.02,
from: "random"
}
}, 0.2);
currentIndex = index;
}
Observer.create({
type: "wheel,touch,pointer",
wheelSpeed: -1,
onDown: () => !animating && gotoSection(currentIndex - 1, -1),
onUp: () => !animating && gotoSection(currentIndex + 1, 1),
tolerance: 10,
preventDefault: true
});
gotoSection(0, 1);
// original: https://codepen.io/BrianCross/pen/PoWapLP
// horizontal version: https://codepen.io/GreenSock/pen/xxWdeMK
vendor/gsap-previews/sources/gsap-6d7d9d29c890/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}
vendor/gsap-previews/sources/gsap-6d7d9d29c890/adapters/script.js실행 안내·자료
window.__STYLEGALLERY_ASSETS__={};
gsap.registerPlugin(Observer);
let sections = document.querySelectorAll("section"), images = document.querySelectorAll(".bg"), headings = gsap.utils.toArray(".section-heading"), outerWrappers = gsap.utils.toArray(".outer"), innerWrappers = gsap.utils.toArray(".inner"), splitHeadings = headings.map((heading) => new SplitText(heading, { type: "chars,words,lines", linesClass: "clip-text" })), currentIndex = -1, wrap = gsap.utils.wrap(0, sections.length), animating;
gsap.set(outerWrappers, { yPercent: 100 });
gsap.set(innerWrappers, { yPercent: -100 });
function gotoSection(index, direction) {
index = wrap(index);
animating = true;
let fromTop = direction === -1, dFactor = fromTop ? -1 : 1, tl = gsap.timeline({
defaults: { duration: 1.25, ease: "power1.inOut" },
onComplete: () => animating = false
});
if (currentIndex >= 0) {
gsap.set(sections[currentIndex], { zIndex: 0 });
tl.to(images[currentIndex], { yPercent: -15 * dFactor }).set(sections[currentIndex], { autoAlpha: 0 });
}
gsap.set(sections[index], { autoAlpha: 1, zIndex: 1 });
tl.fromTo([outerWrappers[index], innerWrappers[index]], {
yPercent: (i) => i ? -100 * dFactor : 100 * dFactor
}, {
yPercent: 0
}, 0).fromTo(images[index], { yPercent: 15 * dFactor }, { yPercent: 0 }, 0).fromTo(splitHeadings[index].chars, {
autoAlpha: 0,
yPercent: 150 * dFactor
}, {
autoAlpha: 1,
yPercent: 0,
duration: 1,
ease: "power2",
stagger: {
each: 0.02,
from: "random"
}
}, 0.2);
currentIndex = index;
}
Observer.create({
type: "wheel,touch,pointer",
wheelSpeed: -1,
onDown: () => !animating && gotoSection(currentIndex - 1, -1),
onUp: () => !animating && gotoSection(currentIndex + 1, 1),
tolerance: 10,
preventDefault: true
});
gotoSection(0, 1);
LICENSE실행 안내·자료
<!--
Copyright (c) 2022 - GreenSock - https://codepen.io/GreenSock/pen/XWzRraJ
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
이 장면을 만드는 원리
전체 화면 입력과 전환 잠금
장면 탐색의 입력 종류, 진행 중 수락 정책과 일반 문서 탐색 대안을 명시합니다.
- 이 예제에서는
- Observer는 wheel·touch·pointer의 방향을 gotoSection으로 연결하고 preventDefault:true로 기본 스크롤을 가로챕니다. gotoSection은 wrap으로 인덱스를 순환시키며 outer·inner를 반대 방향으로 움직이고 글자를 무작위 순서로 드러냅니다. animating 중 입력은 버리며 키보드 장면 버튼은 원본에 없습니다.
