Codrops 원본
Menu to Grid Layout Animation
탐색 · MIT
갤러리 안에서는 화면을 벗어나거나 움직임을 멈추면 예제도 닫힙니다. 다시 재생할 때는 처음부터 시작해요.
SOURCE FILES
원본 코드 읽기
수집한 원본 소스와 실행 안내를 함께 제공합니다.
src/css/base.css
*,
*::after,
*::before {
box-sizing: border-box;
}
:root {
font-size: 14px;
--color-text: #131313;
--color-bg: #fff;
--color-link: #000;
--color-link-hover: #131313;
--padding-sides: 2rem;
--padding-row: 1rem;
--color-row-border: #f0f0f0;
--color-bg-row-hover: #f0f0f0;
--color-text-alt: #000;
--image-gap: 1vw;
--image-gap-large: 2vw;
--img-size: 5vw;
--img-size-large: 14vw;
}
body {
margin: 0;
color: var(--color-text);
background-color: var(--color-bg);
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
overflow-x: hidden;
font-family: auger-mono, monospace;
font-weight: 300;
text-transform: uppercase;
position: relative;
}
.oh {
position: relative;
overflow: hidden;
}
.oh__inner {
will-change: transform;
display: inline-block;
}
/* 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;
}
.hover-line {
overflow: hidden;
position: relative;
}
.hover-line::before {
content: '';
height: 1px;
width: 100%;
background: currentColor;
position: absolute;
top: 92%;
transition: transform 0.3s;
transform-origin: 0% 50%;
}
.hover-line:hover::before {
transform: scaleX(0);
transform-origin: 100% 50%;
}
a:hover {
text-decoration: none;
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;
}
.unbutton:focus {
outline: none;
}
.frame {
width: 100%;
padding: 3rem var(--padding-sides);
display: grid;
grid-template-columns: 1fr;
grid-template-rows: auto auto auto;
grid-template-areas: 'title' 'prevdemo' 'sponsor';
justify-content: start;
grid-row-gap: 1rem;
align-items: end;
justify-items: start;
}
.frame__title {
grid-area: title;
display: flex;
line-height: 1;
}
.frame__title-main {
font-size: 1.953rem;
margin: 0;
font-weight: 400;
font-family: neue-haas-grotesk-display, sans-serif;
text-transform: none;
}
.frame__title-back {
position: relative;
display: flex;
align-items: flex-end;
}
.frame__title-back span {
display: none;
}
.frame__title-back svg {
fill: currentColor;
}
.frame__prevdemo {
grid-area: prevdemo;
}
.intro {
padding: 1rem var(--padding-sides) 3rem;
}
.intro p {
max-width: 860px;
}
.cover {
background: var(--color-bg-row-hover);
width: 100%;
height: 0;
opacity: 0;
pointer-events: none;
z-index: 10;
position: fixed;
left: 0;
will-change: height, top;
}
.content {
position: relative;
z-index: 100;
border-bottom: 1px solid var(--color-row-border);
}
.row {
z-index: 1;
color: var(--color-text);
display: grid;
position: relative;
cursor: pointer;
grid-template-rows: var(--img-size);
grid-template-columns: auto 1fr;
grid-column-gap: 5vw;
align-items: center;
padding: var(--padding-row) var(--padding-sides);
border-top: 1px solid var(--color-row-border);
transition: background-color 0.3s ease-out, border-color 0.3s ease-out;
}
.row:hover {
background-color: var(--color-bg-row-hover);
}
.row--current {
z-index: 11;
transition: border-color 0.3s ease-out;
}
.cell {
position: relative;
}
.cell__title,
.preview__item-title {
margin: 0;
font-size: clamp(1.953rem,4vw,3.052rem);
position: relative;
font-weight: 400;
line-height: 1;
font-family: neue-haas-grotesk-display, sans-serif;
white-space: nowrap;
}
.cell__title--switch {
font-family: lores-22-serif, sans-serif;
font-weight: 700;
}
.cell__title {
display: grid;
grid-template-rows: 100% 100%;
}
.cell--images {
display: grid;
align-content: center;
grid-auto-columns: auto;
grid-auto-flow: column;
grid-gap: var(--image-gap);
justify-content: end;
margin-left: auto;
}
.cell__img {
width: var(--img-size);
display: grid;
position: relative;
grid-template-columns: 100%;
grid-template-rows: auto auto;
will-change: transform, opacity;
opacity: 0;
}
.cell__img-inner {
background-size: cover;
background-position: 50% 50%;
aspect-ratio: 1;
width: 100%;
border-radius: calc(var(--image-gap) / 3);
}
.cell__img-title {
max-width: 100%;
font-size: 1rem;
font-weight: 300;
color: var(--color-text-alt);
margin: 0;
height: 0;
opacity: 0;
white-space: nowrap;
will-change: opacity, transform;
display: none;
}
.page-footer {
padding: 10vw 10vw 5vw;
}
.page-footer__text {
max-width: 860px;
margin: 1.5rem auto;
line-height: 1.5;
}
.page-footer__credits {
padding-top: 10vh;
text-align: center;
}
.preview {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
pointer-events: none;
z-index: 200;
}
.preview__close {
position: absolute;
top: 0;
right: 0;
font-size: 2rem;
font-weight: 400;
line-height: 1;
padding: 2rem;
cursor: pointer;
opacity: 0;
font-family: sans-serif;
}
.preview__close--show {
pointer-events: auto;
}
.preview__item {
width: 100%;
height: 100%;
display: grid;
align-items: center;
justify-items: center;
align-content: center;
grid-gap: 10vh;
height: 0;
opacity: 0;
overflow: hidden;
}
.preview__item--current {
pointer-events: auto;
height: 100vh;
opacity: 1;
}
.preview__item-title {
font-family: lores-22-serif, sans-serif;
font-weight: 700;
font-size: clamp(1.563rem, 6vw, 3.815rem);
}
.grid {
position: relative;
display: grid;
max-width: 1200px;
width: 100%;
grid-gap: var(--image-gap-large);
justify-content: center;
justify-items: center;
--img-size: var(--img-size-large);
grid-template-columns: repeat(4,var(--img-size));
grid-template-rows: repeat(2,var(--img-size));
}
.grid .cell__img {
width: var(--img-size-large);
}
@media screen and (min-width: 61em) {
.frame {
grid-template-rows: auto;
grid-template-areas: 'title prevdemo sponsor';
grid-template-columns: auto auto 1fr;
grid-column-gap: 2rem;
}
:root {
--padding-sides: 4rem;
--padding-row: 2rem;
}
}
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>Menu to Grid Layout Animation | Codrops</title>
<meta name="description" content="A menu that animates to a grid layout using GSAP flip" />
<meta name="keywords" content="gsap, flip, javascript, web design, grid, layout" />
<meta name="author" content="Codrops" />
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" href="https://use.typekit.net/gdf6msi.css">
<link rel="stylesheet" type="text/css" href="css/base.css" />
<script src="https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js"></script>
<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>
</head>
<body class="loading">
<main>
<div class="frame">
<div class="frame__title">
<h1 class="frame__title-main">Menu to Grid Layout Animation</h1>
<a aria-label="Back to the article" class="frame__title-back" href="https://tympanus.net/codrops/?p=65056">
<span class="oh__inner">Back to the article</span>
<svg width="21px" height="21px" 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__prevdemo hover-line" href="http://tympanus.net/Development/GlitchPerspective/">Previous demo</a>
</div>
<section class="intro">
<p>And, strange to say, those insects vying in maternal tenderness with the flower-despoiling tribe of Bees are none other than the Dung-beetles, the dealers in ordure, the scavengers of the meadows contaminated by the herd. </p>
</section>
<section class="content">
<div class="cover"></div>
<div class="row">
<div class="cell cell--text">
<h2 class="cell__title oh"><span class="oh__inner">Nobody's Love</span></h2>
</div>
<div class="cell cell--images">
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/6.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/7.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/8.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/9.avif)"></div>
</div>
</div>
</div>
<div class="row">
<div class="cell cell--text">
<h2 class="cell__title oh"><span class="oh__inner">Good Wings</span></h2>
</div>
<div class="cell cell--images">
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/1.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/2.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/3.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/4.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/5.avif)"></div>
</div>
</div>
</div>
<div class="row">
<div class="cell cell--text">
<h2 class="cell__title oh"><span class="oh__inner">Maniac Fly</span></h2>
</div>
<div class="cell cell--images">
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/10.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/11.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/12.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/13.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/14.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/15.avif)"></div>
</div>
</div>
</div>
<div class="row">
<div class="cell cell--text">
<h2 class="cell__title oh"><span class="oh__inner">Crumble Toe</span></h2>
</div>
<div class="cell cell--images">
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/16.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/17.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/18.avif)"></div>
</div>
</div>
</div>
<div class="row">
<div class="cell cell--text">
<h2 class="cell__title oh"><span class="oh__inner">Finger Wax</span></h2>
</div>
<div class="cell cell--images">
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/19.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/20.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/21.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/22.avif)"></div>
</div>
</div>
</div>
<div class="row">
<div class="cell cell--text">
<h2 class="cell__title oh"><span class="oh__inner">Haunted X</span></h2>
</div>
<div class="cell cell--images">
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/23.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/24.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/25.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/26.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/27.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/28.avif)"></div>
</div>
</div>
</div>
<div class="row">
<div class="cell cell--text">
<h2 class="cell__title oh"><span class="oh__inner">Next Horror</span></h2>
</div>
<div class="cell cell--images">
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/29.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/30.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/1.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/10.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/12.avif)"></div>
</div>
</div>
</div>
</section><!-- /content -->
<section class="preview">
<button class="preview__close unbutton">╳</button>
<div class="preview__item">
<h2 class="preview__item-title oh"><span class="oh__inner">Nobody's Love</span></h2>
<div class="grid">
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/27.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/26.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/25.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/24.avif)"></div>
</div>
</div>
</div>
<div class="preview__item">
<h2 class="preview__item-title oh"><span class="oh__inner">Good Wings</span></h2>
<div class="grid">
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/30.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/29.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/28.avif)"></div>
</div>
</div>
</div>
<div class="preview__item">
<h2 class="preview__item-title oh"><span class="oh__inner">Maniac Fly</span></h2>
<div class="grid">
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/22.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/21.avif)"></div>
</div>
</div>
</div>
<div class="preview__item">
<h2 class="preview__item-title oh"><span class="oh__inner">Crumble Toe</span></h2>
<div class="grid">
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/20.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/19.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/30.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/31.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/2.avif)"></div>
</div>
</div>
</div>
<div class="preview__item">
<h2 class="preview__item-title oh"><span class="oh__inner">Finger Wax</span></h2>
<div class="grid">
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/15.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/14.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/13.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/12.avif)"></div>
</div>
</div>
</div>
<div class="preview__item">
<h2 class="preview__item-title oh"><span class="oh__inner">Haunted X</span></h2>
<div class="grid">
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/11.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/10.avif)"></div>
</div>
</div>
</div>
<div class="preview__item">
<h2 class="preview__item-title oh"><span class="oh__inner">Next Horror</span></h2>
<div class="grid">
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/6.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/8.avif)"></div>
</div>
<div class="cell__img">
<div class="cell__img-inner" style="background-image:url(img/5.avif)"></div>
</div>
</div>
</div>
</section>
<footer class="page-footer">
<p class="page-footer__text">What alacrity around one and the same dropping! Never did adventurers hurrying from the four corners of the earth display such eagerness in working a Californian claim.</p>
<p class="page-footer__text">Before the sun becomes too hot, they are there in their hundreds, large and small, promiscuously, of every sort, shape and size, hastening to carve themselves a slice of the common cake. There are some that work in the open air and scrape the surface; there are some that dig themselves galleries in the thick of the heap, in search of choice veins; others work the lower stratum and bury their spoil without delay in the underlying ground; others—the smallest—stand aside to crumble a morsel that has fallen from the mighty excavations of their more powerful fellow-workers. Some, the newcomers and, no doubt, the hungriest, consume their meal on the spot; but the greater number mean to put by a substance that will allow them to spend long days in plenty, down in some safe retreat. A nice, fresh dropping is not found just when you want it, amid the fields bare of thyme; a windfall of that sort is as manna from the sky; only fortune’s favourites receive so fair a portion. Wherefore the riches of to-day are prudently stored for the morrow.</p>
<p class="page-footer__text">Who is this that trots towards the heap, fearing lest he come too late? His long legs move with a sudden, awkward action, as though driven by some mechanism within his belly; his little red antennæ spread their fan, a sign of anxious greed. He is coming, he has come, not without sending some few banqueters sprawling. It is the Sacred Beetle, clad all in black, the biggest and most famous of our Dung-beetles. Ancient Egypt held him in veneration and looked upon him as a symbol of immortality. Here he now sits at table, beside his fellow-guests, each of whom is giving the last touches to his ball with the flat of his broad fore-legs or else enriching it with yet one more layer before retiring to enjoy the fruit of his labours in peace. Let us follow the construction of the famous ball in all its phases.</p>
<p class="page-footer__text">For his own needs, the Beetle is less fastidious and contents himself with a wholesale selection. The notched shield scoops and digs, eliminates and gathers somewhat at random. The fore-legs play a mighty part in the work. They are flattened, curved into the segment of a circle, supplied with powerful nervures and armed on the outside with five sturdy teeth. If a powerful effort be needed to remove an obstacle or to force a way through the thickest part of the heap, the Dung-beetle makes [6]play with his elbows, that is to say, he flings his toothed legs to right and left and clears a semi-circular space with a vigorous thrust of the rake. Room once made, a different kind of work is found for these same limbs: they collect armfuls of the material raked together by the shield and push it under the insect’s belly, between the four hind-legs. These are shaped for the turner’s trade. The legs, especially the last two, are long and slender, slightly bowed and ending in a very sharp claw. One has but to look at them to recognize a pair of spherical compasses capable of embracing a globular body in their curved branches and improving its form. In fact, their mission is to shape the ball.</p>
<p class="page-footer__credits">
Made by <a href="https://twitter.com/codrops">@codrops</a>
</p>
</footer>
</main>
<script type="module" src="js/index.js"></script>
</body>
</html>함께 쓰는 파일 7개 보기
src/js/index.js
import { preloadImages, preloadFonts } from './utils';
import { Row } from './row';
import { gsap } from 'gsap';
import { Flip } from 'gsap/Flip';
gsap.registerPlugin(Flip);
// preview Items
const previewItems = [...document.querySelectorAll('.preview > .preview__item')];
// initial rows
const rows = [...document.querySelectorAll('.row')];
// cover element
const cover = document.querySelector('.cover');
// close ctrl
const closeCtrl = document.querySelector('.preview > .preview__close');
const body = document.body;
// Row instance array
let rowsArr = [];
rows.forEach((row, position) => {
rowsArr.push(new Row(row, previewItems[position]));
});
let isOpen = false;
let isAnimating = false;
let currentRow = -1;
let mouseenterTimeline;
for (const row of rowsArr) {
row.DOM.el.addEventListener('mouseenter', () => {
if ( isOpen ) return;
gsap.killTweensOf([row.DOM.images, row.DOM.title]);
mouseenterTimeline = gsap.timeline()
.addLabel('start', 0)
.to(row.DOM.images, {
duration: 0.4,
ease: 'power3',
startAt: {
scale: 0.8,
xPercent: 20
},
scale: 1,
xPercent: 0,
opacity: 1,
stagger: -0.035
}, 'start')
.set(row.DOM.title, {transformOrigin: '0% 50%'}, 'start')
.to(row.DOM.title, {
duration: 0.1,
ease: 'power1.in',
yPercent: -100,
onComplete: () => row.DOM.titleWrap.classList.add('cell__title--switch')
}, 'start')
.to(row.DOM.title, {
duration: 0.5,
ease: 'expo',
startAt: {
yPercent: 100,
rotation: 15
},
yPercent: 0,
rotation: 0
}, 'start+=0.1');
});
row.DOM.el.addEventListener('mouseleave', () => {
if ( isOpen ) return;
gsap.killTweensOf([row.DOM.images, row.DOM.title]);
gsap.timeline()
.addLabel('start')
.to(row.DOM.images, {
duration: 0.4,
ease: 'power4',
opacity: 0,
scale: 0.8
}, 'start')
.to(row.DOM.title, {
duration: 0.1,
ease: 'power1.in',
yPercent: -100,
onComplete: () => row.DOM.titleWrap.classList.remove('cell__title--switch')
}, 'start')
.to(row.DOM.title, {
duration: 0.5,
ease: 'expo',
startAt: {
yPercent: 100,
rotation: 15
},
yPercent: 0,
rotation: 0
}, 'start+=0.1');
});
// Open a row and reveal the grid
row.DOM.el.addEventListener('click', () => {
if ( isAnimating ) return;
isAnimating = true;
isOpen = true;
currentRow = rowsArr.indexOf(row);
gsap.killTweensOf([cover, rowsArr.map(row => row.DOM.title)]);
gsap.timeline({
onStart: () => {
body.classList.add('oh');
row.DOM.el.classList.add('row--current');
row.previewItem.DOM.el.classList.add('preview__item--current');
gsap.set(row.previewItem.DOM.images, {opacity: 0});
// set cover to be on top of the row and then animate it to cover the whole page
gsap.set(cover, {
height: row.DOM.el.offsetHeight-1, // minus border width
top: row.DOM.el.getBoundingClientRect()['top'],
opacity: 1
});
gsap.set(row.previewItem.DOM.title, {
yPercent: -100,
rotation: 15,
transformOrigin: '100% 50%'
});
closeCtrl.classList.add('preview__close--show');
},
onComplete: () => isAnimating = false
})
.addLabel('start', 0)
.to(cover, {
duration: 0.9,
ease: 'power4.inOut',
height: window.innerHeight,
top: 0,
}, 'start')
// animate all the titles out
.to(rowsArr.map(row => row.DOM.title), {
duration: 0.5,
ease: 'power4.inOut',
yPercent: (_, target) => {
return target.getBoundingClientRect()['top'] > row.DOM.el.getBoundingClientRect()['top'] ? 100 : -100;
},
rotation: 0
}, 'start')
.add(() => {
mouseenterTimeline.progress(1, false);
const flipstate = Flip.getState(row.DOM.images, {simple: true});
row.previewItem.DOM.grid.prepend(...row.DOM.images);
Flip.from(flipstate, {
duration: 0.9,
ease: 'power4.inOut',
//absoluteOnLeave: true,
stagger: 0.04,
})
// other images in the grid
.to(row.previewItem.DOM.images, {
duration: 0.9,
ease: 'power4.inOut',
startAt: {scale: 0, yPercent: () => gsap.utils.random(0,200)},
scale: 1,
opacity: 1,
yPercent: 0,
stagger: 0.04
}, 0.04*(row.DOM.images.length))
}, 'start')
.to(row.previewItem.DOM.title, {
duration: 1,
ease: 'power4.inOut',
yPercent: 0,
rotation: 0,
onComplete: () => row.DOM.titleWrap.classList.remove('cell__title--switch')
}, 'start')
.to(closeCtrl, {
duration: 1,
ease: 'power4.inOut',
opacity: 1
}, 'start');
});
}
// Close the grid and show back the rows
closeCtrl.addEventListener('click', () => {
if ( isAnimating ) return;
isAnimating = true;
isOpen = false;
const row = rowsArr[currentRow];
gsap.timeline({
defaults: {duration: 0.5, ease: 'power4.inOut'},
onStart: () => body.classList.remove('oh'),
onComplete: () => {
row.DOM.el.classList.remove('row--current');
row.previewItem.DOM.el.classList.remove('preview__item--current');
isAnimating = false;
}
})
.addLabel('start', 0)
.to([row.DOM.images, row.previewItem.DOM.images], {
scale: 0,
opacity: 0,
stagger: 0.04,
onComplete: () => row.DOM.imagesWrap.prepend(...row.DOM.images)
}, 0)
.to(row.previewItem.DOM.title, {
duration: 0.6,
yPercent: 100
}, 'start')
.to(closeCtrl, {
opacity: 0
}, 'start')
// animate cover out
.to(cover, {
ease: 'power4',
height: 0,//,row.DOM.el.offsetHeight-1, // minus border width
top: row.DOM.el.getBoundingClientRect()['top']+row.DOM.el.offsetHeight/2
}, 'start+=0.4')
// fade out cover
.to(cover, {
duration: 0.3,
opacity: 0
}, 'start+=0.9')
// animate all the titles in
.to(rowsArr.map(row => row.DOM.title), {
yPercent: 0,
stagger: {
each: 0.03,
grid: 'auto',
from: currentRow
}
}, 'start+=0.4')
});
// Preload images and fonts
Promise.all([preloadImages('.cell__img-inner'), preloadFonts('gdf6msi')]).then(() => {
document.body.classList.remove('loading')
});src/js/previewItem.js
/**
* Class representing a Preview Item (.preview__item)
*/
export class PreviewItem {
// DOM elements
DOM = {
// main element (.preview__item)
el: null,
// title (.preview__item-title)
title: null,
// grid (.grid)
grid: null,
// images (.cell__img)
images: null
}
/**
* Constructor.
* @param {Element} DOM_el - main element (.preview__item)
*/
constructor(DOM_el) {
this.DOM.el = DOM_el;
this.DOM.title = this.DOM.el.querySelector('.preview__item-title > .oh__inner');
this.DOM.grid = this.DOM.el.querySelector('.grid');
this.DOM.images = [...this.DOM.grid.querySelectorAll('.cell__img')];
}
}src/js/row.js
import { PreviewItem } from './previewItem';
/**
* Class representing a Row (.row)
*/
export class Row {
// DOM elements
DOM = {
// main element (.row)
el: null,
// title (.cell__title > .oh__inner)
title: null,
// title wrap
titleWrap: null,
// images wrap
imagesWrap: null,
// images (.cell__img)
images: null
}
/**
* Constructor.
* @param {Element} DOM_el - main element (.row)
*/
constructor(DOM_el, DOM_previewItem) {
this.DOM.el = DOM_el;
this.previewItem = new PreviewItem(DOM_previewItem);
this.DOM.titleWrap = this.DOM.el.querySelector('.cell__title');
this.DOM.title = this.DOM.titleWrap.querySelector('.oh__inner');
this.DOM.imagesWrap = this.DOM.el.querySelector('.cell--images');
this.DOM.images = [...this.DOM.imagesWrap.querySelectorAll('.cell__img')];
}
}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);
});
};
/**
* Preload fonts
* @param {String} id
*/
const preloadFonts = id => {
return new Promise((resolve) => {
WebFont.load({
typekit: {
id: id
},
active: resolve
});
});
};
export {
preloadImages,
preloadFonts,
};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.
BEHIND THE EXAMPLE
