Codrops 원본

Stack to Content Layout Transition

섹션 · MIT

섹션 더 보기
ORIGINAL PREVIEW
Stack to Content Layout Transition 정적 미리보기

갤러리 안에서는 화면을 벗어나거나 움직임을 멈추면 예제도 닫힙니다. 다시 재생할 때는 처음부터 시작해요.

큰 화면으로 보기 새 탭

SOURCE FILES

원본 코드 읽기

9개 파일

수집한 원본 소스와 실행 안내를 함께 제공합니다.

src/css/base.css
파일 저장

*,
*::after,
*::before {
	box-sizing: border-box;
}

:root {
	font-size: 15px;
	margin: 0;
	position: relative;
	--color-text: #fff;
	--color-text-alt: #787878;
	--color-bg: #000;
	--color-link: #fff;
	--color-link-hover: #ccc;
	--page-padding: 2rem;

	/* Stack and slideshow */
	--stack-margin: 10rem;
	--slide-gap: 2vh;
	--stack-width: 38vw;
	--stack-item-height: 8vh;
	--slide-width: 40vw;
	--slide-height: 50vh;
}

body {
	margin: 0;
	position: relative;
	color: var(--color-text);
	background-color: var(--color-bg);
	font-family: acumin-pro, sans-serif;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

/* 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;
}

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;
}

.oh {
	position: relative;
	overflow: hidden;
}

.oh__inner {
	display: inline-block;
	will-change: transform;
}

.unbutton {
	background: none;
	border: 0;
	padding: 0;
	margin: 0;
	color: inherit;
	font: inherit;
}

.unbutton:focus {
	outline: none;
}

.frame {
	padding: 1.5rem 5vw 0;
	z-index: 100;
	text-align: center;
	position: relative;
	position: absolute;
	width: 100%;
}

.frame__title {
	display: flex;
	justify-content: center;
	flex-wrap: wrap;
}

.frame__title-main {
	font-size: 1rem;
	margin: 0;
	font-weight: normal;
}

.frame__title-back {
	position: relative;
	display: flex;
	align-items: flex-end;
}

.frame__title-back span {
	display: none;
}

.frame__title-back svg {
	fill: #fff;
}

.frame__title-prev {
	width: 100%;
}

.frame__logo {
	line-height: 0.9;
}

.frame__logo-title {
	font-family: wayfinder-cf, serif;
	font-weight: 100;
	font-style: normal;
	font-size: 2.75rem;
	margin: 0;
}

.frame__logo-subtitle {
	margin-left: 0.75rem;
}

.stack-wrap {
	width: 100%;
	position: absolute;
    top: 0;
}

.stack {
	margin: 0 auto;
	width: var(--stack-width);
	min-width: 300px;
	grid-gap: 2vh;
	display: grid;
	place-items: center;
}

.stack__item {
	opacity: 0.2;
	width: 100%;
	height: var(--stack-item-height);
	background-size: cover;
	background-position: center;
	cursor: pointer;
	will-change: width, height, transform, opacity;
	transition: opacity 0.3s;
}

.stack__item:hover {
	opacity: 0.5;
}

.stack__item--empty {
	pointer-events: none;
	height: var(--stack-margin);
}

.slides {
	width: 100%;
	position: relative;
	background: var(--color-bg);
}

.slides .stack {
	width: 100%;
	margin-left: auto;
	margin-right: var(--slide-gap);
}

.slides .stack__item {
	pointer-events: none;
	opacity: 0.5;
	height: var(--slide-height);
}

.slides .stack__item--current {
	opacity: 0.6;
}

.title {
	position: fixed;
	bottom: 0;
	left: 50vw;
	margin-bottom: 15vh;
	pointer-events: none;
}

.title__main {
	font-size: 11vw;
	margin: 0;
	font-family: wayfinder-cf, serif;
	font-weight: 100;
	line-height: 1;
}

.title__sub {
	display: block;
	margin-top: -1.5vw;
	line-height: 1;
	font-size: clamp(1rem,2.5vw,2.5rem);
	margin-left: 0.25vw;
	font-weight: 200;
}

.content {
	position: fixed;
	pointer-events: none;
	top: 0;
	left: 0;
	z-index: 100;
	display: grid;
	height: 100vh;
	width: 100%;
	padding: var(--page-padding);
	grid-template-areas: '...' 'back' 'slides' '...';
	grid-template-columns: 1fr;
	grid-template-rows: auto auto 1fr auto;
	grid-gap: var(--slide-gap);
}

.content__item {
	grid-area: slides;
	overflow: hidden;
	position: absolute;
	height: 0;
	opacity: 0;
	pointer-events: none;
}

.content__item--current {
	overflow: visible;
	position: relative;
	pointer-events: auto;
	height: auto;
	opacity: 1;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: flex-start;
}

.content__item-title {
	font-family: wayfinder-cf, serif;
	font-weight: 100;
	line-height: 1;
	font-size: clamp(2rem,9vw,10rem);
	margin: 0 0 2rem 0;
	color: #c87e4f;
}

.content__item-title > span {
	display: block;
	white-space: nowrap;
	line-height: 1;
}

.content__item-title > span:not(:first-child) {
	margin-top: -1vw;
}

.content__back {
	grid-area: back;
	display: flex;
	align-items: center;
	cursor: pointer;
	opacity: 0;
	pointer-events: none;
}

.content__back svg {
	fill: #fff;
	margin-right: 0.5rem;
}

.content__nav-wrap {
	grid-area: 1 / 1 / -1 / -1;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
}

.content__nav {
	z-index: 100;
	cursor: pointer;
	opacity: 0;
	flex: none;
	align-self: center;
	pointer-events: none;
	height: calc((100vh - var(--slide-height) - var(--slide-gap) * 4) / 3);
}

.content__nav svg {
	stroke: #fff;
	stroke-width: 3px;
    width: auto;
    height: 100%;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.content__nav:hover svg,
.content__nav:focus-visible svg {
	opacity: 1;
}

.content__nav--next svg {
	transform: scale(-1);
}

.content--open .content__back,
.content--open .content__nav {
	opacity: 1;
	pointer-events: auto;
}

@media screen and (min-width: 53em) {
	:root {
		--stack-margin: 50vh;
	}
	.frame {
		text-align: left;
		top: 0;
		left: 0;
		display: grid;
		align-content: space-between;
		max-width: none;
		position: fixed;
		height: 100vh;
		z-index: 1000;
		padding: var(--page-padding);
		pointer-events: none;
		grid-template-columns: auto auto 1fr;
		grid-template-rows: auto auto auto;
		grid-template-areas: 'logo ... sponsor'
							'... ...  ...'
							'title title ...';
	}
	.frame__title {
		grid-area: title;
		justify-content: flex-start;
		color: var(--color-text-alt);
	}
	.frame__logo {
		grid-area: logo;
	}
	.frame a {
		pointer-events: auto;
	}
	.content {
		grid-template-areas: 'back slides'
							'title slides'	
							'... slides';
		grid-template-columns: 1fr 50vw;
		grid-template-rows: auto 1fr 10vh;
		grid-column-gap: var(--page-padding);
		padding: var(--page-padding) var(--slide-gap) var(--page-padding) var(--page-padding);
	}
	.content__item {
		grid-area: title;
		align-self: end;
		text-align: left;
	}
	.content__item-title {
		display: inline-flex;
		flex-direction: column;
	}
	.content__item-title > span:first-child {
		padding-right: 2rem;
	}
	.content__item-title > span:last-child {
		margin-left: auto;
	}
	.content__item-description {
		max-width: 300px;
	}
	.content__back {
		grid-area: back;
		justify-self: end;
	}
	.content__nav-wrap {
		grid-area: slides; 
	}
	.slides {
		background: transparent;
		width: 50vw;
		margin-left: auto;
		margin-right: var(--slide-gap);
	}
	.slides .stack__item--current {
		opacity: 1;
	}
}
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>Stack to Content Layout Transition | Codrops</title>
		<!-- Generate Meta Tags via https://www.opengraph.xyz -->
		<meta name="description" content="An experimental layout transition where a stack of images animates to a gallery view, showing some more content." />
		<meta name="keywords" content="stack, layout transition, menu, gallery, gsap, javascript" />
		<meta name="author" content="Codrops" />
		<link rel="shortcut icon" href="favicon.ico">
		<link rel="stylesheet" href="https://use.typekit.net/mai4fgw.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="demo-1 loading">
		<main>
			<div class="frame">
				<div class="frame__title">
					<h1 class="frame__title-main">Stack to Content Layout Transition</h1>
					<a aria-label="Back to the article" class="frame__title-back" href="https://tympanus.net/codrops/?p=63558">
						<span class="oh__inner">Back to the article</span>
						<svg width="18px" height="18px" viewBox="0 0 24 24"><path fill-rule="evenodd" 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"/></svg>
					</a>
					<br/>
					<a class="frame__title-prev" href="https://tympanus.net/Development/IntroTrailEffect/">Previous demo</a>
				</div>
				<div class="frame__logo">
					<h2 class="frame__logo-title">Jonas Tanaka</h2>
					<span class="frame__logo-subtitle">フォトグラフィー</span>
				</div>
			</div>
			<div class="content">
				<div class="content__item">
					<h2 class="content__item-title">
						<span class="oh"><span class="oh__inner">Queen of </span></span><span class="oh"><span class="oh__inner">the Sea</span></span></h2>
					<div class="content__item-description">
						<p class="oh"><strong class="oh__inner">Osaka, 1986</strong></p>
						<p class="oh"><span class="oh__inner">Hidesato felt very sorry for the Dragon King on hearing his story, and readily promised to do what he could to help him.</span></p>
					</div>
				</div>
				<div class="content__item">
					<h2 class="content__item-title"><span class="oh"><span class="oh__inner">Hinata's</span></span><span class="oh"><span class="oh__inner">Trouble</span></span></h2>
					<div class="content__item-description">
						<p class="oh"><strong class="oh__inner">Kyoto, 1986</strong></p>
						<p class="oh"><span class="oh__inner">His power was immense, for he was the ruler of all sea creatures both great and small, and in his keeping were the Jewels of the Ebb and Flow of the Tide.</span></p>
					</div>
				</div>
				<div class="content__item">
					<h2 class="content__item-title"><span class="oh"><span class="oh__inner">Dragon's</span></span><span class="oh"><span class="oh__inner">Journey</span></span></h2>
					<div class="content__item-description">
						<p class="oh"><strong class="oh__inner">Nagoya, 1986</strong></p>
						<p class="oh"><span class="oh__inner">Calling all his fish retainers together, he chose several of them as ambassadors to go through the sea and seek for a young Dragon Princess who would be his bride.</span></p>
					</div>
				</div>
				<div class="content__item">
					<h2 class="content__item-title"><span class="oh"><span class="oh__inner">Prince</span></span><span class="oh"><span class="oh__inner">Yamato</span></span></h2>
					<div class="content__item-description">
						<p class="oh"><strong class="oh__inner">Tokyo, 1986</strong></p>
						<p class="oh"><span class="oh__inner">The King fell in love with her at once, and the wedding ceremony was celebrated with great splendor. </span></p>
					</div>
				</div>
				<div class="content__item">
					<h2 class="content__item-title"><span class="oh"><span class="oh__inner">Kumaso</span></span><span class="oh"><span class="oh__inner">&amp; Haru</span></span></h2>
					<div class="content__item-description">
						<p class="oh"><strong class="oh__inner">Sapporo, 1986</strong></p>
						<p class="oh"><span class="oh__inner">When the hare heard these kind words he felt very grateful to the man, and encouraged by his gentle manner the hare told him all that had befallen him.</span></p>
					</div>
				</div>
				<div class="content__item">
					<h2 class="content__item-title"><span class="oh"><span class="oh__inner">Botan's</span></span><span class="oh"><span class="oh__inner">Dream</span></span></h2>
					<div class="content__item-description">
						<p class="oh"><strong class="oh__inner">Sendai, 1986</strong></p>
						<p class="oh"><span class="oh__inner">Okuni-nushi-no-Mikoto is worshiped by the people in some parts of Japan, as a god, and the hare has become famous as “The White Hare of Inaba”. </span></p>
					</div>
				</div>
				<div class="content__item">
					<h2 class="content__item-title"><span class="oh"><span class="oh__inner">The Gate</span></span><span class="oh"><span class="oh__inner">of Rashoi</span></span></h2>
					<div class="content__item-description">
						<p class="oh"><strong class="oh__inner">Kyoto, 1986</strong></p>
						<p class="oh"><span class="oh__inner">Nearly two thousand years ago this sword was kept at the shrines of Ite, the temples dedicated to the worship of Amaterasu, the great and beautiful Sun Goddess from whom the Japanese Emperors are said to be descended.</span></p>
					</div>
				</div>
				<div class="content__item">
					<h2 class="content__item-title"><span class="oh"><span class="oh__inner">Faithful</span></span><span class="oh"><span class="oh__inner">Knights</span></span></h2>
					<div class="content__item-description">
						<p class="oh"><strong class="oh__inner">Kobe, 1986</strong></p>
						<p class="oh"><span class="oh__inner">At last King Keiko ordered his younger son Prince Yamato to subdue the brigands and, if possible, to rid the land of their evil lives.</span></p>
					</div>
				</div>
				<div class="content__item">
					<h2 class="content__item-title"><span class="oh"><span class="oh__inner">Five Colors</span></span><span class="oh"><span class="oh__inner">for Jokwa</span></span></h2>
					<div class="content__item-description">
						<p class="oh"><strong class="oh__inner">Hiroshima, 1986</strong></p>
						<p class="oh"><span class="oh__inner">There is a story of knightly adventure and daring which explains why the name of the sword was changed from that of Murakumo to Kasanagi, which means grass clearing.</span></p>
					</div>
				</div>
				<div class="content__item">
					<h2 class="content__item-title"><span class="oh"><span class="oh__inner">Shikuyu's</span></span><span class="oh"><span class="oh__inner">Charm</span></span></h2>
					<div class="content__item-description">
						<strong class="oh"><span class="oh__inner">Kumamoto, 1986</span></strong></p>
						<p class="oh"><span class="oh__inner">He at once made ready to start, and great was the stir in the precincts of the Palace as he and his trusty followers gathered together and prepared for the expedition, and polished up their armor and donned it.</span></p>
					</div>
				</div>
				<button class="content__back unbutton">
					<svg aria-hidden="true" width="16px" height="16px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
						<path d="M11.4939 20.5644C11.1821 20.8372 10.7083 20.8056 10.4356 20.4939L3.43557 12.4939C3.18814 12.2111 3.18814 11.7889 3.43557 11.5061L10.4356 3.50613C10.7083 3.1944 11.1822 3.16281 11.4939 3.43557C11.8056 3.70834 11.8372 4.18216 11.5644 4.49388L5.65283 11.25L20 11.25C20.4142 11.25 20.75 11.5858 20.75 12C20.75 12.4142 20.4142 12.75 20 12.75L5.65283 12.75L11.5644 19.5061C11.8372 19.8179 11.8056 20.2917 11.4939 20.5644Z"/>
					</svg>
					<span class="oh__inner">Back</span>
				</button>
				<nav class="content__nav-wrap">
					<button class="content__nav content__nav--prev unbutton">
						<svg width="100" height="267" viewBox="0 0 100 267"><path d="M49.894 2.766v262.979" stroke-linecap="square"/><path fill="none" d="M99.75 76.596C73.902 76.596 52.62 43.07 49.895 0 47.168 43.07 25.886 76.596.036 76.596"/></svg>
					</button>
					<button class="content__nav content__nav--next unbutton">
						<svg width="100" height="267" viewBox="0 0 100 267"><path d="M49.894 2.766v262.979" stroke-linecap="square"/><path fill="none" d="M99.75 76.596C73.902 76.596 52.62 43.07 49.895 0 47.168 43.07 25.886 76.596.036 76.596"/></svg>
					</button>
				</nav>
			</div>
			<div class="slides"></div>
			<div class="stack-wrap">
				<div class="stack">
					<div class="stack__item stack__item--empty"></div>
					<div class="stack__item" style="background-image:url(img/1.jpg);"></div>
					<div class="stack__item" style="background-image:url(img/2.jpg);"></div>
					<div class="stack__item" style="background-image:url(img/3.jpg);"></div>
					<div class="stack__item" style="background-image:url(img/4.jpg);"></div>
					<div class="stack__item" style="background-image:url(img/5.jpg);"></div>
					<div class="stack__item" style="background-image:url(img/6.jpg);"></div>
					<div class="stack__item" style="background-image:url(img/7.jpg);"></div>
					<div class="stack__item" style="background-image:url(img/8.jpg);"></div>
					<div class="stack__item" style="background-image:url(img/9.jpg);"></div>
					<div class="stack__item" style="background-image:url(img/10.jpg);"></div>
					<div class="stack__item stack__item--empty"></div>
				</div>
			</div>
			<div class="title">
				<h2 class="title__main oh"><span class="oh__inner">Photography</span></span></h2>
				<span class="title__sub oh"><span class="oh__inner">1986 &mdash; 2022</span></span>
			</div>
		</main>
		<script type="module" src="js/index.js"></script>
		<script src="https://tympanus.net/codrops/adpacks/cda_sponsor.js"></script>
	</body>
</html>
함께 쓰는 파일 7개 보기
src/js/contentItem.js
파일 저장

/**
 * Class representing a Content Item
 */
 export class ContentItem {
    // DOM elements
	DOM = {
		// main element (.content__item)
		el: null,
        // title (.content__item-title)
        title: null,
        // description (.content__item-description)
        description: null,
        // all .oh__inner text spans that will animate in/out
        texts: null
	}
    
    /**
	 * Constructor.
	 * @param {NodeList} DOM_el - main element (.content__item)
	 */
	constructor(DOM_el) {
		this.DOM.el = DOM_el;
        this.DOM.title = this.DOM.el.querySelector('.content__item-title');
        this.DOM.description = this.DOM.el.querySelector('.content__item-description');

        this.DOM.texts = [...this.DOM.el.querySelectorAll('.oh > .oh__inner')];
	}
}
src/js/index.js
파일 저장

import { preloadImages } from './utils';
import { Slideshow } from './slideshow';

const slideshow = new Slideshow(document.querySelector('.stack'));

// Preload images
preloadImages('.stack__item').then( _ => document.body.classList.remove('loading'));
src/js/slideshow.js
파일 저장

import { ContentItem } from './contentItem';
import { gsap } from 'gsap';
import { Flip } from 'gsap/Flip';
gsap.registerPlugin(Flip);
import { Observer } from 'gsap/Observer';
gsap.registerPlugin(Observer);

const body = document.body;

let winsize = {width: window.innerWidth, height: window.innerHeight};
window.addEventListener('resize', () => {
	winsize = {width: window.innerWidth, height: window.innerHeight};
});

/**
 * Class representing the Slideshow
 */
export class Slideshow {
	// DOM elements
	DOM = {
		// main element (.stack)
		el: null,
		// stack items (.stack__item)
		items: null,

		// the DOM location of the .stacks element when the slideshow is closed
		stackWrap: document.querySelector('.stack-wrap'),
		// the DOM location of the .stacks element when the slideshow is open
		slides: document.querySelector('.slides'),
		
		// .content element
		content: document.querySelector('.content'),
		// the content items (.content__item)
		contentItems: [...document.querySelectorAll('.content__item')],
		
		// the main title ("Photography")
		mainTitleTexts: [...document.querySelectorAll('.title > .oh > .oh__inner')],

		// back control (.content__back)
		backCtrl: document.querySelector('.content__back'),
		// navigation (.content__nav-wrap)
		nav: document.querySelector('.content__nav-wrap'),
		// navigation arrows
		navArrows: {
			prev: document.querySelector('.content__nav--prev'),
			next: document.querySelector('.content__nav--next'),
		}
	}
	// Content instances
	contentItems = [];
	// Check is Slishow is in open mode or closed mode
	isOpen = false;
	// Current item's position
	current = -1;
	// Total items
	totalItems = 0;
	// items gap (CSS variable)
	gap = getComputedStyle(document.documentElement).getPropertyValue('--slide-gap');

	/**
	 * Constructor.
	 * @param {NodeList} DOM_el - main element (.stack)
	 */
	constructor(DOM_el) {
		this.DOM.el = DOM_el;
		
		this.DOM.items = [...this.DOM.el.querySelectorAll('.stack__item:not(.stack__item--empty)')];
		this.totalItems = this.DOM.items.length;
		this.DOM.contentItems.forEach(item => this.contentItems.push(new ContentItem(item)));

		this.initEvents();
	}
	/**
	 * Event binding.
	 */
	initEvents() {
		
		this.DOM.items.forEach((item, position) => {
			// Clicking on a stack item reveals the slideshow navigation and the item's content
			item.addEventListener('click', () => {
				// Show the item's content
				this.open(item);
			});
		});

		this.DOM.backCtrl.addEventListener('click', () => {
			this.close();
		});

		this.DOM.navArrows.next.addEventListener('click', () => {
			this.navigate('next');
		});
		this.DOM.navArrows.prev.addEventListener('click', () => {
			this.navigate('prev');
		});

		// Trigger the close() on scroll by using the gsap observer plugin
		const scrollFn = () => {
			if ( this.isOpen && !this.isAnimating ) {
				this.close();
				this.scrollObserver.disable();
			}
		}
		this.scrollObserver = Observer.create({
			type: 'wheel,touch,pointer',
			wheelSpeed: -1,
			onDown: scrollFn,
			onUp: scrollFn,
			tolerance: 10,
			preventDefault: true,
		})
		this.scrollObserver.disable();

	}
	/**
	 * Opens the slideshow navigation and reveals the item's content.
	 * @param {NodeList} stackItem - the clicked item
	 */
	open(stackItem) {

		if ( this.isAnimating || this.isOpen ) {
			return;
		}
		this.isAnimating = true;
		
		// Update the current value
		this.current = this.DOM.items.indexOf(stackItem);

		// enable the observer (closes teh slideshow on scroll/touch)
		this.scrollObserver.enable();

		const scrollY = window.scrollY;
		
		body.classList.add('oh');
		this.DOM.content.classList.add('content--open');
		
		// set CSS current classes to both content and stack item elements
		this.contentItems[this.current].DOM.el.classList.add('content__item--current');
		this.DOM.items[this.current].classList.add('stack__item--current');

		const state = Flip.getState(this.DOM.items, {props: 'opacity'});
		this.DOM.slides.appendChild(this.DOM.el);

		const itemCenter = stackItem.offsetTop + stackItem.offsetHeight/2;
		
		// seems to solve a bug in firefox
		document.documentElement.scrollTop = document.body.scrollTop = 0;

		gsap.set(this.DOM.el, {
			y: winsize.height/2 - itemCenter + scrollY
		});		
		
		// seems to solve a bug in firefox
		document.documentElement.scrollTop = document.body.scrollTop = 0;

		// Flip
		Flip.from(state, {
			duration: 1,
			ease: 'expo',
			onComplete: () => {
				this.isOpen = true;
				this.isAnimating = false;
			},
			// seems to solve a bug in firefox
			onStart: () => document.documentElement.scrollTop = document.body.scrollTop = scrollY,
			absoluteOnLeave: true,
		})
		.to(this.DOM.mainTitleTexts, {
			duration: .9,
			ease: 'expo',
			yPercent: -101
		}, 0)
		.to(this.contentItems[this.current].DOM.texts, {
			duration: 1,
			ease: 'expo',
			startAt: {yPercent: 101},
			yPercent: 0
		}, 0)
		.to(this.DOM.backCtrl, {
			duration: 1,
			ease: 'expo',
			startAt: {opacity: 0},
			opacity: 1
		}, 0)
		.to([this.DOM.navArrows.prev, this.DOM.navArrows.next], {
			duration: 1,
			ease: 'expo',
			startAt: {
				opacity: 0,
				y: pos => pos ? -150 : 150
			},
			y: 0,
			opacity: pos => this.current === 0 && !pos || this.current === this.totalItems-1 && pos ? 0 : 1
		}, 0);

	}
	/**
	 * Closes the slideshow navigation and hides the content
	 */
	close() {

		if ( this.isAnimating || !this.isOpen ) {
			return;
		}
		this.isAnimating = true;

		this.scrollObserver.disable();

		this.DOM.items[this.current].classList.remove('stack__item--current');

		body.classList.remove('oh');
		
		const state = Flip.getState(this.DOM.items, {props: 'opacity'});
		this.DOM.stackWrap.appendChild(this.DOM.el);

		gsap.set(this.DOM.el, {
			y: 0
		});

		// Flip
		Flip.from(state, {
			duration: 1,
			ease: 'expo',
			onComplete: () => {
				this.DOM.content.classList.remove('content--open');
				this.contentItems[this.current].DOM.el.classList.remove('content__item--current');

				this.current = -1;
				this.isOpen = false;
				this.isAnimating = false;
			},
			absoluteOnLeave: true
		})
		.to(this.DOM.mainTitleTexts, {
			duration: .9,
			ease: 'expo',
			startAt: {yPercent: 101},
			yPercent: 0
		}, 0)
		.to(this.contentItems[this.current].DOM.texts, {
			duration: 1,
			ease: 'expo',
			yPercent: -101
		}, 0)
		.to(this.DOM.backCtrl, {
			duration: 1,
			ease: 'expo',
			opacity: 0
		}, 0)
		.to([this.DOM.navArrows.prev, this.DOM.navArrows.next], {
			duration: 1,
			ease: 'expo',
			y: pos => pos ? 100 : -100,
			opacity: 0
		}, 0);
	}
	/**
	 * Navigation
	 * @param {String} direction 'prev' || 'next'
	 */
	navigate(direction) {
		
		if ( this.isAnimating || (direction === 'next' && this.current === this.totalItems-1) || (direction === 'prev' && this.current === 0) ) return;
		this.isAnimating = true;

		const previousCurrent = this.current;
		const currentItem = this.DOM.items[previousCurrent];
		this.current = direction === 'next' ? this.current+1 : this.current-1
		const upcomingItem = this.DOM.items[this.current];
		
		currentItem.classList.remove('stack__item--current');
		upcomingItem.classList.add('stack__item--current');

		// show/hide arrows
		gsap.set(this.DOM.navArrows.prev, {opacity: this.current > 0 ? 1 : 0});
		gsap.set(this.DOM.navArrows.next, {opacity: this.current < this.totalItems-1 ? 1 : 0});
		
		gsap.timeline()
		.to(this.DOM.el, {
			duration: 1,
			ease: 'expo',
			y: direction === 'next' ? `-=${winsize.height/2 + winsize.height*.02}` : `+=${winsize.height/2 + winsize.height*.02}`,
			onComplete: () => {
				this.isAnimating = false;
			}
		})
		.to(this.contentItems[previousCurrent].DOM.texts, {
			duration: .2,
			ease: 'power1',
			yPercent: direction === 'next' ? 101 : -101,
			onComplete: () => this.contentItems[previousCurrent].DOM.el.classList.remove('content__item--current')
		}, 0)
		.to(this.contentItems[this.current].DOM.texts, {
			duration: .9,
			ease: 'expo',
			startAt: {yPercent: direction === 'next' ? -101 : 101},
			onStart: () => this.contentItems[this.current].DOM.el.classList.add('content__item--current'),
			yPercent: 0
		}, .2)
	}
}
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);
    });
};

export {
    preloadImages
};
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.