Codrops 원본
On-Scroll Animation and View Switch
스크롤 · MIT
갤러리 안에서는 화면을 벗어나거나 움직임을 멈추면 예제도 닫힙니다. 다시 재생할 때는 처음부터 시작해요.
SOURCE FILES
원본 코드 읽기
수집한 원본 소스와 실행 안내를 함께 제공합니다.
src/css/base.css
*,
*::after,
*::before {
box-sizing: border-box;
}
:root {
font-size: 18px;
--color-text: #5e5754;
--color-title: #944d3e;
--color-bg: #080808;
--color-link: #5e5754;
--color-link-hover: #5e5754;
--color-switch-bg: #f1e4dd;
--color-switch: #000;
--color-switch-active: #c1b7b1;
--color-heading: #f1e4dd;
}
html {
scroll-behavior: initial;
}
html,
body {
width: 100%;
min-height: 100%;
}
body {
margin: 0;
color: var(--color-text);
background-color: var(--color-bg);
font-family: articulat-cf, -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
body #cdawrap {
justify-self: start;
}
.oh {
position: relative;
overflow: hidden;
}
.oh__inner {
will-change: transform;
display: inline-block;
}
.line {
transform-origin: 0;
white-space: nowrap;
will-change: transform;
}
/* Page Loader */
.js .loading::before,
.js .loading::after {
content: '';
position: fixed;
z-index: 1000;
}
.js .loading::before {
top: 0;
left: 0;
width: 100%;
height: 100%;
background: var(--color-bg);
}
.js .loading::after {
top: 50%;
left: 50%;
width: 60px;
height: 60px;
margin: -30px 0 0 -30px;
border-radius: 50%;
opacity: 0.4;
background: var(--color-link);
animation: loaderAnim 0.7s linear infinite alternate forwards;
}
@keyframes loaderAnim {
to {
opacity: 1;
transform: scale3d(0.5,0.5,1);
}
}
a {
text-decoration: none;
color: var(--color-link);
outline: none;
cursor: pointer;
}
a:hover {
color: var(--color-link-hover);
outline: none;
}
/* Better focus styles from https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible */
a:focus {
/* Provide a fallback style for browsers
that don't support :focus-visible */
outline: none;
background: lightgrey;
}
a:focus:not(:focus-visible) {
/* Remove the focus indicator on mouse-focus for browsers
that do support :focus-visible */
background: transparent;
}
a:focus-visible {
/* Draw a very noticeable focus style for
keyboard-focus on browsers that do support
:focus-visible */
outline: 2px solid red;
background: transparent;
}
.unbutton {
background: none;
border: 0;
padding: 0;
margin: 0;
font: inherit;
cursor: pointer;
color: currentColor;
}
.unbutton:focus {
outline: none;
}
.frame {
position: relative;
color: var(--color-title);
padding: 1rem;
display: grid;
grid-template-columns: 100%;
grid-template-rows: auto auto auto;
grid-template-areas: 'title' 'prev' 'sponsor';
justify-content: start;
justify-items: start;
margin-bottom: 3rem;
grid-gap: 0.5rem;
}
.frame a:not(.frame__title-back) {
white-space: nowrap;
overflow: hidden;
position: relative;
}
.frame a:not(.frame__title-back)::before {
content: '';
height: 1px;
width: 100%;
background: currentColor;
position: absolute;
top: 90%;
transition: transform 0.3s;
transform-origin: 0% 50%;
}
.frame a:not(.frame__title-back):hover::before {
transform: scaleX(0);
transform-origin: 100% 50%;
}
.frame__title {
grid-area: title;
display: flex;
}
.frame__title-main {
font-size: 1rem;
margin: 0;
font-weight: normal;
}
.frame__title-back {
position: relative;
display: flex;
align-items: flex-end;
margin-bottom: 0.15rem;
}
.frame__title-back span {
display: none;
}
.frame__title-back svg {
fill: currentColor;
}
.frame__prev {
grid-area: prev;
}
.heading {
position: fixed;
top: 6rem;
left: 0;
width: 100%;
z-index: 200;
pointer-events: none;
mix-blend-mode: color-dodge;
}
.heading__main {
display: inline-block;
color: var(--color-heading);
font-weight: 300;
font-size: clamp(2rem,10vw,5.5rem);
white-space: nowrap;
margin: 0;
margin-left: calc(13.25vw + 25vw + 1vw);
line-height: 0.8;
text-transform: uppercase;
margin-top: 1rem;
will-change: transform;
}
.heading__sub {
display: inline-block;
margin-left: calc(13.25vw + 25vw + 1vw + 1rem);
color: var(--color-heading);
font-size: 0.85rem;
}
.switch {
padding: 1rem 1.5rem;
position: fixed;
background: var(--color-switch-bg);
bottom: 1.5rem;
left: 50%;
transform: translateX(-50%);
display: flex;
z-index: 100;
border-radius: 3rem;
}
.switch::after {
content: '';
width: 1px;
height: calc(100% - 2rem);
position: absolute;
left: 50%;
background: var(--color-switch-active);
}
.switch__button {
display: flex;
margin: 0 0.5rem;
padding: 0 0.25rem;
fill: var(--color-switch);
}
.switch__button--current {
fill: var(--color-switch-active);
pointer-events: none;
}
.switch__button svg {
pointer-events: none;
}
.content {
position: relative;
padding: 20vh 13.25vw 2.5rem;
}
.grid-open {
overflow: hidden;
height: 100vh;
}
.grid-open .content {
pointer-events: none;
}
.item {
grid-gap: 5vh;
grid-template-columns: 100%;
align-content: center;
justify-content: center;
display: grid;
grid-template-areas: 'caption' 'img';
margin: 0 auto 20vh;
}
.item__image-wrap {
grid-area: img;
width: 100%;
aspect-ratio: 800/500;
justify-self: center;
}
.item__image {
width: 100%;
aspect-ratio: 800/500;
position: relative;
overflow: hidden;
will-change: transform;
}
.item__image-inner {
width: 100%;
height: 100%;
background-size: cover;
will-change: transform;
}
.item__caption {
grid-area: caption;
position: relative;
z-index: 10;
}
.item__caption-title {
white-space: nowrap;
width: min-content;
line-height: 1.2;
font-size: clamp(2rem,6vw,3.5rem);
font-weight: 300;
margin: 0;
color: var(--color-title);
}
.item__caption-description {
max-width: 200px;
line-height: 1.2;
}
.item__caption-number {
display: inline-block;
}
.grid {
width: 100%;
pointer-events: none;
position: fixed;
top: 0;
display: grid;
grid-template-columns: repeat(5,1fr);
grid-gap: 1rem;
height: 100vh;
left: 0;
align-content: center;
padding: 2rem;
}
.grid-open .grid {
pointer-events: auto;
}
.grid .item__image {
cursor: not-allowed;
}
.grid .item__image:nth-child(1) {
grid-row: 1;
grid-column: 1;
}
.grid .item__image:nth-child(2) {
grid-row: 1;
grid-column: 2;
}
.grid .item__image:nth-child(3) {
grid-row: 1;
grid-column: 3;
}
.grid .item__image:nth-child(3) {
grid-row: 1;
grid-column: 3;
}
.grid .item__image:nth-child(4) {
grid-row: 2;
grid-column: 1;
}
.grid .item__image:nth-child(5) {
grid-row: 2;
grid-column: 3;
}
.grid .item__image:nth-child(6) {
grid-row: 2;
grid-column: 5;
}
.grid .item__image:nth-child(7) {
grid-row: 3;
grid-column: 1;
}
.grid .item__image:nth-child(8) {
grid-row: 3;
grid-column: 2;
}
.grid .item__image:nth-child(9) {
grid-row: 3;
grid-column: 4;
}
.grid .item__image:nth-child(10) {
grid-row: 4;
grid-column: 1;
}
.grid .item__image:nth-child(11) {
grid-row: 4;
grid-column: 3;
}
.grid .item__image:nth-child(12) {
grid-row: 4;
grid-column: 5;
}
@media screen and (min-width: 53em) {
.frame {
grid-column-gap: 2rem;
grid-template-columns: auto auto;
grid-template-rows: auto auto;
grid-template-areas: 'title prev' 'sponsor ...';
}
.item {
grid-gap: 1vw;
grid-template-columns: 25vw 1fr;
grid-template-areas: 'caption img' ;
}
.content {
padding-top: 40vh;
}
.content .item__image {
grid-column: 2 / span 2;
}
.heading {
top: 0;
}
.grid {
left: calc((100vw - 950px ) / 2);
max-width: 950px;
}
}src/index.html
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>On-Scroll Animations and View Switch | Codrops</title>
<meta name="description" content="A layout with some scroll animations and a view switch where the content items animate to a grid." />
<meta name="keywords" content="layout, gsap, javascript, switch, grid, smooth scrolling, lenis, flip plugin" />
<meta name="author" content="Codrops" />
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" href="https://use.typekit.net/eur8cof.css">
<link rel="stylesheet" type="text/css" href="css/base.css" />
<script>document.documentElement.className="js";var supportsCssVars=function(){var e,t=document.createElement("style");return t.innerHTML="root: { --tmp-var: bold; }",document.head.appendChild(t),e=!!(window.CSS&&window.CSS.supports&&window.CSS.supports("font-weight","var(--tmp-var)")),t.parentNode.removeChild(t),e};supportsCssVars()||alert("Please view this demo in a modern browser that supports CSS Variables.");</script>
<script src="//tympanus.net/codrops/adpacks/analytics.js"></script>
</head>
<body class="loading">
<main>
<div class="frame">
<div class="frame__title">
<h1 class="frame__title-main">On-Scroll Animations & View Switch</h1>
<a aria-label="Back to the article" class="frame__title-back" href="https://tympanus.net/codrops/?p=65117">
<span class="oh__inner">Back to the article</span>
<svg width="18px" height="18px" viewBox="0 0 24 24"><path vector-effect="non-scaling-stroke" d="M18.25 15.5a.75.75 0 00.75-.75v-9a.75.75 0 00-.75-.75h-9a.75.75 0 000 1.5h7.19L6.22 16.72a.75.75 0 101.06 1.06L17.5 7.56v7.19c0 .414.336.75.75.75z"></path>
</svg>
</a>
</div>
<a class="frame__prev" href="http://tympanus.net/Development/MenuToGrid/">Previous demo</a>
</div>
<div class="heading">
<h2 class="heading__main">Projects * Insomnia * Projects * Insomnia * Projects * Insomnia * Projects</h2>
<span class="heading__sub">1984 - 2022</span>
</div>
<div class="switch">
<button class="unbutton switch__button switch__button--grid">
<svg width="18px" height="18px" viewBox="0 0 45 45">
<rect x="0" y="0" width="20" height="20"></rect>
<rect x="25" y="0" width="20" height="20"></rect>
<rect x="0" y="25" width="20" height="20"></rect>
<rect x="25" y="25" width="20" height="20"></rect>
</svg>
</button>
<button class="unbutton switch__button switch__button--list switch__button--current">
<svg width="18px" height="18px" viewBox="0 0 43 43">
<rect x="0" y="0" width="11" height="11"></rect>
<rect x="16" y="0" width="25" height="11"></rect>
<rect x="16" y="16" width="25" height="11"></rect>
<rect x="16" y="32" width="25" height="11"></rect>
<rect x="0" y="16" width="11" height="11"></rect>
<rect x="0" y="32" width="11" height="11"></rect>
</svg>
</button>
</div>
<div class="content">
<figure class="item">
<figcaption class="item__caption">
<span class="item__caption-number oh"><span class="oh__inner">01</span></span>
<h2 class="item__caption-title oh"><span class="oh__inner">Cast a spell</span></h2>
<p class="item__caption-description">
All natural and technological processes
Proceed in such a way that the availability
Of the remaining energy decreases</p>
</figcaption>
<div class="item__image-wrap"><div class="item__image"><div class="item__image-inner" style="background-image:url(img/1.jpg)"></div></div></div>
</figure>
<figure class="item">
<figcaption class="item__caption">
<span class="item__caption-number oh"><span class="oh__inner">02</span></span>
<h2 class="item__caption-title oh"><span class="oh__inner">Corruption</span></h2>
<p class="item__caption-description">
In all energy exchanges, if no energy
Enters or leaves an isolated system
The entropy of that system increases</p>
</figcaption>
<div class="item__image-wrap"><div class="item__image"><div class="item__image-inner" style="background-image:url(img/2.jpg)"></div></div></div>
</figure>
<figure class="item">
<figcaption class="item__caption">
<span class="item__caption-number oh"><span class="oh__inner">03</span></span>
<h2 class="item__caption-title oh"><span class="oh__inner">All their lives</span></h2>
<p class="item__caption-description">
All natural and technological processes
Proceed in such a way that the availability
Of the remaining energy decreases</p>
</figcaption>
<div class="item__image-wrap"><div class="item__image"><div class="item__image-inner" style="background-image:url(img/3.jpg)"></div></div></div>
</figure>
<figure class="item">
<figcaption class="item__caption">
<span class="item__caption-number oh"><span class="oh__inner">04</span></span>
<h2 class="item__caption-title oh"><span class="oh__inner">You'll burn in hell</span></h2>
<p class="item__caption-description">
All natural and technological processes
Proceed in such a way that the availability
Of the remaining energy decreases</p>
</figcaption>
<div class="item__image-wrap"><div class="item__image"><div class="item__image-inner" style="background-image:url(img/4.jpg)"></div></div></div>
</figure>
<figure class="item">
<figcaption class="item__caption">
<span class="item__caption-number oh"><span class="oh__inner">05</span></span>
<h2 class="item__caption-title oh"><span class="oh__inner">What we become</span></h2>
<p class="item__caption-description">
All natural and technological processes
Proceed in such a way that the availability
Of the remaining energy decreases</p>
</figcaption>
<div class="item__image-wrap"><div class="item__image"><div class="item__image-inner" style="background-image:url(img/5.jpg)"></div></div></div>
</figure>
<figure class="item">
<figcaption class="item__caption">
<span class="item__caption-number oh"><span class="oh__inner">06</span></span>
<h2 class="item__caption-title oh"><span class="oh__inner">Take a bow</span></h2>
<p class="item__caption-description">
All natural and technological processes
Proceed in such a way that the availability
Of the remaining energy decreases</p>
</figcaption>
<div class="item__image-wrap"><div class="item__image"><div class="item__image-inner" style="background-image:url(img/6.jpg)"></div></div></div>
</figure>
<figure class="item">
<figcaption class="item__caption">
<span class="item__caption-number oh"><span class="oh__inner">07</span></span>
<h2 class="item__caption-title oh"><span class="oh__inner">You bring death</span></h2>
<p class="item__caption-description">
All natural and technological processes
Proceed in such a way that the availability
Of the remaining energy decreases</p>
</figcaption>
<div class="item__image-wrap"><div class="item__image"><div class="item__image-inner" style="background-image:url(img/7.jpg)"></div></div></div>
</figure>
<figure class="item">
<figcaption class="item__caption">
<span class="item__caption-number oh"><span class="oh__inner">08</span></span>
<h2 class="item__caption-title oh"><span class="oh__inner">You must pay</span></h2>
<p class="item__caption-description">
All natural and technological processes
Proceed in such a way that the availability
Of the remaining energy decreases</p>
</figcaption>
<div class="item__image-wrap"><div class="item__image"><div class="item__image-inner" style="background-image:url(img/8.jpg)"></div></div></div>
</figure>
<figure class="item">
<figcaption class="item__caption">
<span class="item__caption-number oh"><span class="oh__inner">09</span></span>
<h2 class="item__caption-title oh"><span class="oh__inner">Feed the hex</span></h2>
<p class="item__caption-description">
All natural and technological processes
Proceed in such a way that the availability
Of the remaining energy decreases</p>
</figcaption>
<div class="item__image-wrap"><div class="item__image"><div class="item__image-inner" style="background-image:url(img/9.jpg)"></div></div></div>
</figure>
<figure class="item">
<figcaption class="item__caption">
<span class="item__caption-number oh"><span class="oh__inner">10</span></span>
<h2 class="item__caption-title oh"><span class="oh__inner">Beg for their lives</span></h2>
<p class="item__caption-description">
All natural and technological processes
Proceed in such a way that the availability
Of the remaining energy decreases</p>
</figcaption>
<div class="item__image-wrap"><div class="item__image"><div class="item__image-inner" style="background-image:url(img/10.jpg)"></div></div></div>
</figure>
<figure class="item">
<figcaption class="item__caption">
<span class="item__caption-number oh"><span class="oh__inner">11</span></span>
<h2 class="item__caption-title oh"><span class="oh__inner">For all your sins</span></h2>
<p class="item__caption-description">
All natural and technological processes
Proceed in such a way that the availability
Of the remaining energy decreases</p>
</figcaption>
<div class="item__image-wrap"><div class="item__image"><div class="item__image-inner" style="background-image:url(img/11.jpg)"></div></div></div>
</figure>
<figure class="item">
<figcaption class="item__caption">
<span class="item__caption-number oh"><span class="oh__inner">12</span></span>
<h2 class="item__caption-title oh"><span class="oh__inner">Beholden</span></h2>
<p class="item__caption-description">
All natural and technological processes
Proceed in such a way that the availability
Of the remaining energy decreases</p>
</figcaption>
<div class="item__image-wrap"><div class="item__image"><div class="item__image-inner" style="background-image:url(img/12.jpg)"></div></div></div>
</figure>
</div>
<div class="grid">
</div>
</main>
<script src="https://tympanus.net/codrops/adpacks/cda_sponsor.js"></script>
</body>
<script type="module" src="js/index.js"></script>
</html>
함께 쓰는 파일 7개 보기
src/js/index.js
import { preloadImages, isInViewport } from './utils';
import { Item } from './item';
import Lenis from '@studio-freight/lenis'
import { gsap } from 'gsap';
import { ScrollTrigger } from 'gsap/ScrollTrigger';
gsap.registerPlugin(ScrollTrigger);
import { Flip } from 'gsap/Flip';
gsap.registerPlugin(Flip);
// Item instances (Item is the .content > figure.item)
const items = [];
[...document.querySelectorAll('.item')].forEach(item => {
items.push(new Item(item));
});
// Toggle grid view
const switchCtrl = {
grid: document.querySelector('.switch__button--grid'),
list: document.querySelector('.switch__button--list')
};
// Text element that moves horizontally as we scroll
const heading = {
el: document.querySelector('.heading'),
main: document.querySelector('.heading .heading__main'),
}
// Placeholder for the grid items (.item__image). We'll use the gsap FLIP plugin to move the "".item .item__image" inside the grid element
const grid = document.querySelector('.grid');
// Lenis smooth scrolling
let lenis;
// Initialize Lenis smooth scrolling
const initSmoothScrolling = () => {
lenis = new Lenis({
lerp: 0.1,
smooth: true,
});
const scrollFn = (time) => {
lenis.raf(time);
requestAnimationFrame(scrollFn);
};
requestAnimationFrame(scrollFn);
};
// ScrollTrigger animations for scrolling
const animateOnScroll = () => {
for (const item of items) {
gsap.set(item.DOM.imageInner, {transformOrigin: '50% 0%'});
gsap.timeline({
scrollTrigger: {
trigger: item.DOM.el,
start: 'top bottom',
end: 'bottom top',
scrub: true
}
})
.addLabel('start', 0)
// scale up the inner image
.to(item.DOM.imageInner, {
ease: 'none',
scaleY: 2.4,
scaleX: 1.2,
opacity: 0
}, 'start')
// translate the title and number
.to([item.DOM.title, item.DOM.number], {
ease: 'none',
yPercent: -150,
}, 'start')
// translate the inner title/number (overflow is hidden so they get hidden)
.to([item.DOM.titleInner, item.DOM.numberInner], {
scrollTrigger: {
trigger: item.DOM.el,
start: 'top bottom',
end: 'top 20%',
scrub: true,
},
ease: 'expo.in',
yPercent: -100
}, 'start')
/*
.to(item.DOM.description, {
scrollTrigger: {
trigger: item.DOM.el,
start: 'top bottom',
end: 'bottom top',
scrub: true,
},
ease: 'none',
yPercent: 100
}, 'start')
*/
}
// animate the heading element as we scroll (horizontally)
let windowWidth = window.innerWidth;
gsap.to(heading.main, {
scrollTrigger: {
start: 0,
end: 'max',
scrub: true
},
ease: 'none',
x: () => -heading.main.offsetWidth - (13.25*windowWidth/100 + 25*windowWidth/100 + windowWidth/100) + windowWidth
});
};
const showGrid = () => {
document.body.classList.add('grid-open');
// stop the smooth scrolling
lenis.stop();
// get the DOM elements that we'll work with
const DOM = getDOMElements();
// Disable active ScrollTrigger instances
let Alltrigger = ScrollTrigger.getAll();
for (let i = 0; i < Alltrigger.length; i++) {
Alltrigger[i].disable(false);
}
// Use gsap flip for the animation
// save the current state of the images
const flipstate = Flip.getState(DOM.allImages);
// put them inside the .grid element
grid.append(...DOM.allImages);
// gsap stagger properties
const staggerConfig = {
grid: 'auto',
// the order goes from the first item inside the viewport
from: DOM.inViewportItems.length ? items.indexOf(DOM.inViewportItems[0]) : 0,
amount: 0.06,
};
// Flip it
Flip.from(flipstate, {
duration: 0.7,
ease: 'power3.inOut',
scale: true,
stagger: staggerConfig
})
// Also reset scales applied to the inner images (items inside the viewport)
.to(DOM.inViewportImagesInner, {
duration: 0.7,
ease: 'power3.inOut',
scaleX: 1,
scaleY: 1,
opacity: 1,
stagger: staggerConfig
}, 0)
// For the items outside of the viewport, simply reset the scales with no animation
.set(DOM.outViewportImagesInner, {
scaleX: 1,
scaleY: 1,
opacity: 1
}, 0)
// hide the titles and numbers inner elments by translating them up
.to([DOM.inViewportTitlesInner, DOM.inViewportNumbersInner], {
duration: 0.4,
ease: 'power3.inOut',
yPercent: -100,
opacity: 0
}, 0)
// hide description
.to(DOM.inViewportDescription, {
duration: 0.4,
ease: 'power3.inOut',
opacity: 0
}, 0)
// For all the items outside the viewport, simply set opacity to 0
.set([DOM.outViewportTitlesInner, DOM.outViewportNumbersInner, DOM.outViewportDescription], {
opacity: 0,
}, 0)
// hide the heading element
.to(heading.el, {
duration: 0.7,
ease: 'power3.inOut',
yPercent: -100,
x: -100
}, 0);
};
const hideGrid = () => {
document.body.classList.remove('grid-open');
// restart the smooth scrolling
lenis.start();
// get the DOM elements that we'll work with
const DOM = getDOMElements();
const flipstate = Flip.getState([DOM.allImages, DOM.allImagesInner], {props: 'opacity'});
DOM.allImages.forEach((image,pos) => {
items[pos].DOM.imageWrap.appendChild(image)
});
// Enable ScrollTrigger instances
let Alltrigger = ScrollTrigger.getAll();
for (let i = 0; i < Alltrigger.length; i++) {
Alltrigger[i].enable(false);
}
Flip.from(flipstate, {
duration: 0.7,
ease: 'power3.inOut',
scale: true,
})
.to([DOM.inViewportTitlesInner, DOM.inViewportNumbersInner, DOM.inViewportDescription], {
duration: 0.4,
ease: 'power3.inOut',
startAt: {opacity: 0},
opacity: 1
}, 0)
.set([DOM.outViewportTitlesInner, DOM.outViewportNumbersInner, DOM.outViewportDescription], {
opacity: 1
}, 0)
.to(heading.el, {
duration: 0.7,
ease: 'power3.inOut',
yPercent: 0,
x: 0
}, 0);
}
// Returns some DOM elements that are needed for showing/hiding the grid
const getDOMElements = () => {
const inViewportItems = items.filter(item => isInViewport(item.DOM.el));
const outViewportItems = items.filter(n => !inViewportItems.includes(n));
return {
allImages: items.map(item => item.DOM.image),
allImagesInner: items.map(item => item.DOM.imageInner),
inViewportItems: inViewportItems,
outViewportItems: outViewportItems,
inViewportImagesInner: inViewportItems.map(item => item.DOM.imageInner),
outViewportImagesInner: outViewportItems.map(item => item.DOM.imageInner),
inViewportDescription: inViewportItems.map(item => item.DOM.description),
outViewportDescription: outViewportItems.map(item => item.DOM.description),
inViewportTitlesInner: inViewportItems.map(item => item.DOM.titleInner),
outViewportTitlesInner: outViewportItems.map(item => item.DOM.titleInner),
inViewportNumbersInner: inViewportItems.map(item => item.DOM.numberInner),
outViewportNumbersInner: outViewportItems.map(item => item.DOM.numberInner)
};
}
// Initialize the events
const initEvents = () => {
// show grid ctrl click
switchCtrl.grid.addEventListener('click', () => {
switchCtrl.grid.classList.add('switch__button--hidden', 'switch__button--current');
switchCtrl.list.classList.remove('switch__button--hidden', 'switch__button--current');
showGrid();
});
// hide grid ctrl click
switchCtrl.list.addEventListener('click', () => {
switchCtrl.list.classList.add('switch__button--hidden', 'switch__button--current');
switchCtrl.grid.classList.remove('switch__button--hidden', 'switch__button--current');
hideGrid();
});
};
// Preload images
preloadImages('.item__image-inner').then(() => {
document.body.classList.remove('loading');
initSmoothScrolling();
animateOnScroll();
initEvents();
});src/js/item.js
/**
* Class representing an Item element (.item)
*/
export class Item {
// DOM elements
DOM = {
// main element (.item)
el: null,
// caption (.item__caption)
caption : null,
// imageWrap (.item__image-wrap)
imageWrap: null,
// image (.item__image)
image: null,
// imageInner (.item__image > .item__image-inner)
imageInner: null,
// title (.item__caption-title)
title: null,
// titleInner (.item__caption-title > .oh__inner)
titleInner: null,
// number (.item__caption-number)
number: null,
// numberInner (.item__caption-number > .oh__inner)
numberInner: null,
// description (.item__caption-description)
description: null,
};
/**
* Constructor.
* @param {Element} DOM_el - main element (.item)
*/
constructor(DOM_el) {
this.DOM.el = DOM_el;
this.DOM.caption = this.DOM.el.querySelector('.item__caption');
this.DOM.imageWrap = this.DOM.el.querySelector('.item__image-wrap');
this.DOM.image = this.DOM.el.querySelector('.item__image');
this.DOM.imageInner = this.DOM.image.querySelector('.item__image-inner');
this.DOM.title = this.DOM.el.querySelector('.item__caption-title');
this.DOM.titleInner = this.DOM.title.querySelector('.oh__inner');
this.DOM.number = this.DOM.el.querySelector('.item__caption-number');
this.DOM.numberInner = this.DOM.number.querySelector('.oh__inner');
this.DOM.description = this.DOM.el.querySelector('.item__caption-description');
}
}src/js/preloader.js
const imagesLoaded = require('imagesloaded');
const body = document.body;
export const preloader = selector => {
return new Promise(resolve => {
const imgwrap = document.createElement('div');
imgwrap.style.visibility = 'hidden';
body.appendChild(imgwrap);
[...document.querySelectorAll(selector)].forEach(el => {
const imgEl = document.createElement('img');
imgEl.style.width = 0;
imgEl.src = el.getAttributeNS('http://www.w3.org/1999/xlink', 'href');
imgEl.className = 'preload';
imgwrap.appendChild(imgEl);
});
imagesLoaded(document.querySelectorAll('.preload'), () => {
imgwrap.parentNode.removeChild(imgwrap);
body.classList.remove('loading');
resolve();
});
});
};src/js/utils.js
const imagesLoaded = require('imagesloaded');
/**
* Preload images
* @param {String} selector - Selector/scope from where images need to be preloaded. Default is 'img'
*/
const preloadImages = (selector = 'img') => {
return new Promise((resolve) => {
imagesLoaded(document.querySelectorAll(selector), {background: true}, resolve);
});
};
/**
* Wraps the elements of an array.
* @param {Array} arr - the array of elements to be wrapped
* @param {String} wrapType - the type of the wrap element ('div', 'span' etc)
* @param {String} wrapClass - the wrap class(es)
*/
const wrapLines = (arr, wrapType, wrapClass) => {
arr.forEach(el => {
const wrapEl = document.createElement(wrapType);
wrapEl.classList = wrapClass;
el.parentNode.appendChild(wrapEl);
wrapEl.appendChild(el);
});
}
/**
* Checks if an element is in the viewport
* @param {Element} elem - the element to be checked
*/
const isInViewport = elem => {
var bounding = elem.getBoundingClientRect();
return (
(bounding.bottom >= 0 && bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight) || bounding.top >= 0 && bounding.top <= (window.innerHeight || document.documentElement.clientHeight)) &&
(bounding.right >= 0 && bounding.right <= (window.innerWidth || document.documentElement.clientWidth) || bounding.left >= 0 && bounding.left <= (window.innerWidth || document.documentElement.clientWidth))
);
};
export {
preloadImages,
wrapLines,
isInViewport,
};Media credits and license evidence실행 안내·자료
README.md
## Credits
- Images from [Unsplash](https://unsplash.com/)
## License
[MIT](LICENSE)
Made with :blue_heart: by [Codrops](http://www.codrops.com)
LICENSE실행 안내·자료
MIT License
Copyright (c) 2009 - 2021 [Codrops](https://tympanus.net/codrops)
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.
Bundled dependency licenses실행 안내·자료
GSAP standard license snapshot
Source: https://gsap.com/community/standard-license/
Retrieved: 2026-09-22T04:22:49.089Z
Original distribution copyright and version headers remain in the runtime code.
Standard "No Charge" GSAP License
I. DEFINITIONS
“GSAP License” means the terms and conditions of this GSAP Software License Agreement.
"GSAP Products" means any Software made available at gsap.com (https://gsap.com) or any successor sites, including but not limited to the GSAP animation library and related plugins, tools, or extensions.
"Permitted Uses" means the implementation and/or use of GSAP Products on any website, web application, or digital interface by any person or entity (which may include, for clarity, those of companies that compete with Webflow in other areas of business).
"Prohibited Uses" means any implementation and/or use of GSAP Products in tools that allow users to build visual animations without code that encourages, induces, or materially assists in creating a solution that competes with Webflow’s visual animation building capabilities.
"Competitive Products" means any software, tool, or service that enables users to create, edit, or manage animations through a visual interface or builder similar to Webflow (https://webflow.com).
II. GRANT OF LICENSE
Subject to the terms and conditions of this GSAP License, Webflow grants you a non-exclusive, worldwide license to use, reproduce, display, and implement GSAP Products solely for Permitted Uses.
III. RESTRICTIONS
You may not:
Use any GSAP Products for any Prohibited Uses without prior written consent;
Reverse engineer any GSAP Products for the purpose of creating Competitive Products;
Remove or alter any proprietary notices or branding from GSAP Products.
IV. OWNERSHIP AND INTELLECTUAL PROPERTY
All intellectual property rights in GSAP Products, including but not limited to copyright, patents, trademarks, and trade secrets, remain the exclusive property of Webflow. This GSAP License does not transfer any ownership rights in GSAP Products to you.
V. TERMINATION
Webflow may terminate this GSAP License and revoke your access in its discretion if you fail to comply with any of these terms and conditions. Upon termination, you must cease all use of GSAP Products and destroy all copies in your possession.
VI. MISCELLANEOUS PROVISIONS
General: This GSAP License is incorporated into and subject to Webflow’s Terms of Service available here (https://webflow.com/legal/terms) ("Terms of Service"). In the event of any conflict or inconsistency between this GSAP License and the Terms of Service, the terms of this GSAP License shall govern in relation to your use of any GSAP Products.
Amendments: Webflow reserves the right to update or modify this GSAP License at any time by posting the revised terms on this website, provided that any such updates or modifications shall not result in any material degradation to the security, integrity, or functionality of any GSAP Products. You understand and agree that your continued use of any GSAP Products after such revisions to this GSAP License constitutes your acceptance of this GSAP License as revised. If you do not accept the revised GSAP License, you are prohibited from using versions of the GSAP Products released after the effective date of the revised GSAP License (as well as any updates made to previous versions). Notwithstanding, you may continue using previous versions of GSAP Products under the applicable terms licensed to you prior to the effective date of the revised GSAP License (for clarity, excluding any updates made thereto).
No Waiver: Failure of Webflow to enforce any provision of this GSAP License shall not constitute a waiver of future enforcement of that or any other provision.
FAQ
Is it acceptable for AI tools like ChatGPT, Cursor, Lovable, Webstudio, etc. to generate GSAP code?
Absolutely! AI-generated code is not a "Prohibited Use".
What if a WordPress plugin or theme or other niche tool allows users to create GSAP-driven effects through a visual interface? Is that prohibited?
We want to encourage developers to build on top of GSAP, including visual tools that don't directly compete with Webflow's rich animation-building capabilities. If you are not sure if your product might be considered a "Prohibited Use", feel free to contact us (https://gsap.com/contact) so we can talk through it!
Can I really use GSAP in commercial projects without paying anything?
Yes, really! Commercial usage is covered under the standard license. All of GSAP including the plugins that were formerly "members-only" like SplitText (https://gsap.com/docs/v3/Plugins/SplitText/) and MorphSVG (https://gsap.com/docs/v3/Plugins/MorphSVGPlugin) can be used in commercial projects at no charge. Enjoy! 💚
Effective date: April 30, 2025
Last modified date: May 30, 2025
Copyright (©) 2025, Webflow
ev-emitter@2.1.2 — LICENSE.md
Copyright (c) 2016-2021 [David DeSandro](https://desandro.com)
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.
imagesloaded@5.0.0 — LICENSE.md
Copyright (c) 2011-2022 [David DeSandro](https://desandro.com) and [contributors](https://github.com/desandro/imagesloaded/graphs/contributors)
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.
tiny-emitter@2.1.0 — LICENSE
The MIT License (MIT)
Copyright (c) 2017 Scott Corgan
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.
virtual-scroll@2.2.1 — LICENSE
The MIT License (MIT)
Copyright (c) 2014 Florian Morel
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.
BEHIND THE EXAMPLE
이 장면을 만드는 원리
스크롤이 숨긴 이미지와 격자 보기의 충돌
반복 입력에서 현재 의도와 전환의 종료·취소 책임을 명시합니다.
- 이 예제에서는
- 목록의 스크롤 효과는 imageInner를 세로 2.4배·가로 1.2배로 늘리며 opacity를 0으로 만듭니다. 같은 항목을 별도 버튼으로 격자 보기로 전환합니다.
