GSAP 원본
Scrubbed bento gallery
스크롤 · MIT (public Pen panels); GSAP Standard No Charge License
갤러리 안에서는 화면을 벗어나거나 움직임을 멈추면 예제도 닫힙니다. 다시 재생할 때는 처음부터 시작해요.
저장한 HTML에서는 갤러리의 재생 설정이 적용되지 않아요.
SOURCE FILES
원본 코드 읽기
수집한 원본 소스와 실행 안내를 함께 제공합니다. 실행 HTML에는 미리보기를 위한 실행 환경이 들어 있습니다.
vendor/gsap-previews/sources/gsap-6f33bfb390f0/index.html
<div class="gallery-wrap">
<div class="gallery gallery--bento gallery--switch" id="gallery-8">
<div class="gallery__item">
<img src="https://assets.codepen.io/16327/portrait-pattern-1.jpg" alt="" />
</div>
<div class="gallery__item">
<img src="https://assets.codepen.io/16327/portrait-image-12.jpg" alt="" />
</div>
<div class="gallery__item">
<img src="https://assets.codepen.io/16327/portrait-image-8.jpg" alt="" />
</div>
<div class="gallery__item">
<img src="https://assets.codepen.io/16327/portrait-pattern-2.jpg" alt="" />
</div>
<div class="gallery__item">
<img src="https://assets.codepen.io/16327/portrait-image-4.jpg" alt="" />
</div>
<div class="gallery__item">
<img src="https://assets.codepen.io/16327/portrait-image-3.jpg" alt="" />
</div>
<div class="gallery__item">
<img src="https://assets.codepen.io/16327/portrait-pattern-3.jpg" alt="" />
</div>
<div class="gallery__item">
<img src="https://assets.codepen.io/16327/portrait-image-1.jpg" alt="" />
</div>
</div>
</div>
<div class="section">
<h2>Here is some content</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>vendor/gsap-previews/sources/gsap-6f33bfb390f0/style.css
p {
font-size: 1.2rem;
margin-bottom: 1rem;
}
.gallery-wrap {
position: relative;
width: 100%;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
}
.gallery {
position: relative;
width: 100%;
height: 100%;
flex: none;
}
.gallery__item {
background-position: 50% 50%;
background-size: cover;
flex: none;
position: relative;
img {
object-fit: cover;
width: 100%;
height: 100%;
}
}
.gallery--bento {
display: grid;
gap: 1vh;
grid-template-columns: repeat(3, 32.5vw);
grid-template-rows: repeat(4, 23vh);
justify-content: center;
align-content: center;
}
.gallery--final.gallery--bento {
grid-template-columns: repeat(3, 100vw);
grid-template-rows: repeat(4, 49.5vh);
gap: 1vh;
}
.gallery--bento .gallery__item:nth-child(1) {
grid-area: 1 / 1 / 3 / 2;
}
.gallery--bento .gallery__item:nth-child(2) {
grid-area: 1 / 2 / 2 / 3;
}
.gallery--bento .gallery__item:nth-child(3) {
grid-area: 2 / 2 / 4 / 3;
}
.gallery--bento .gallery__item:nth-child(4) {
grid-area: 1 / 3 / 3 / 3;
}
.gallery--bento .gallery__item:nth-child(5) {
grid-area: 3 / 1 / 3 / 2;
}
.gallery--bento .gallery__item:nth-child(6) {
grid-area: 3 / 3 / 5 / 4;
}
.gallery--bento .gallery__item:nth-child(7) {
grid-area: 4 / 1 / 5 / 2;
}
.gallery--bento .gallery__item:nth-child(8) {
grid-area: 4 / 2 / 5 / 3;
}
.section {
padding: 2rem 5rem;
}
함께 쓰는 파일 4개 보기
vendor/gsap-previews/sources/gsap-6f33bfb390f0/script.js
console.clear();
gsap.registerPlugin(ScrollTrigger);
gsap.registerPlugin(Flip);
let flipCtx;
const createTween = () => {
let galleryElement = document.querySelector("#gallery-8");
let galleryItems = galleryElement.querySelectorAll(".gallery__item");
console.log(flipCtx);
flipCtx && flipCtx.revert();
galleryElement.classList.remove("gallery--final");
flipCtx = gsap.context(() => {
// Temporarily add the final class to capture the final state
galleryElement.classList.add("gallery--final");
const flipState = Flip.getState(galleryItems);
galleryElement.classList.remove("gallery--final");
const flip = Flip.to(flipState, {
simple: true,
ease: "expoScale(1, 5)"
});
const tl = gsap.timeline({
scrollTrigger: {
trigger: galleryElement,
start: "center center",
end: "+=100%",
scrub: true,
pin: galleryElement.parentNode
// markers: true
}
});
tl.add(flip);
return () => gsap.set(galleryItems, { clearProps: "all" });
});
};
createTween();
window.addEventListener("resize", createTween);
vendor/gsap-previews/sources/gsap-6f33bfb390f0/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-6f33bfb390f0/adapters/script.js실행 안내·자료
window.__STYLEGALLERY_ASSETS__={};
console.clear();
gsap.registerPlugin(ScrollTrigger);
gsap.registerPlugin(Flip);
let flipCtx;
const createTween = () => {
let galleryElement = document.querySelector("#gallery-8");
let galleryItems = galleryElement.querySelectorAll(".gallery__item");
console.log(flipCtx);
flipCtx && flipCtx.revert();
galleryElement.classList.remove("gallery--final");
flipCtx = gsap.context(() => {
galleryElement.classList.add("gallery--final");
const flipState = Flip.getState(galleryItems);
galleryElement.classList.remove("gallery--final");
const flip = Flip.to(flipState, {
simple: true,
ease: "expoScale(1, 5)"
});
const tl = gsap.timeline({
scrollTrigger: {
trigger: galleryElement,
start: "center center",
end: "+=100%",
scrub: true,
pin: galleryElement.parentNode
// markers: true
}
});
tl.add(flip);
return () => gsap.set(galleryItems, { clearProps: "all" });
});
};
createTween();
window.addEventListener("resize", createTween);
LICENSE실행 안내·자료
<!--
Copyright (c) 2024 - GreenSock - https://codepen.io/GreenSock/pen/vYMzKZx
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
이 장면을 만드는 원리
최종 배치 측정과 크기 변경 재구성
장면의 진행률과 재측정할 기하를 구분하고 이전 효과를 정리한 뒤 다시 구성합니다.
- 이 예제에서는
- createTween은 기존 flipCtx를 revert한 다음 gallery--final을 잠시 붙여 최종 상태를 캡처합니다. 클래스를 제거한 현재 배치에서 Flip.to로 향하고 이를 pin·scrub 타임라인에 넣습니다. resize는 같은 함수로 다시 구성하며 컨텍스트 정리 함수가 항목의 inline 표현을 비웁니다.
