Codrops 원본

Inline Layout Switch Ideas

섹션 · MIT

섹션 더 보기
ORIGINAL PREVIEW
Inline Layout Switch Ideas 정적 미리보기

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

큰 화면으로 보기 새 탭

SOURCE FILES

원본 코드 읽기

10개 파일

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

src/css/base.css
파일 저장

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

:root {
	font-size: 16px;
	--color-text: #fff;
	--color-text-alt: rgba(114,116,114,0.6);
	--color-link: #ccc;
	--color-link-hover: #fff;
	--color-bg: #000;
	--padding-ver: 0.5rem;
	--padding-hor: 0.5rem;
	--cursor-stroke: #cc1111;
}

.demo-2 {
	--color-text-alt: rgba(193,193,193,0.8);
}

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

/* 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: 40px;
	height: 40px;
	margin: -20px 0 0 -20px;
	opacity: 0.5;
	background: var(--color-text-alt);
	animation: loaderAnim 0.7s linear infinite forwards;

}

@keyframes loaderAnim {
	to {
		transform: rotate(360deg)
	}
}

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: var(--color-text);
}

.unbutton:focus {
	outline: none;
}

main {
	display: grid;
	height: 100vh;
	padding: 0;
	position: relative;
}

.oh {
	position: relative;
	display: inline-block;
	overflow: hidden;
}

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

.frame {
	z-index: 100;
	padding: var(--padding-hor) var(--padding-ver);
	grid-gap: .5rem;
	pointer-events: none;
	text-transform: uppercase;
	width: 100%;
	grid-template: "title" "prev" "sponsor" "nav" / 100%;
	grid-template-rows: repeat(4, min-content);
	grid-area: 1 / 1 / 2 / 2;
	justify-content: start;
	justify-items: start;
	font-size: .75rem;
	display: grid;
	position: relative;
}

.frame a {
	pointer-events: auto
}

.frame a:not(.frame__title-back) {
	white-space: nowrap;
	position: relative;
	overflow: hidden
}

.frame a:not(.frame__title-back):before {
	content: "";
	height: 1px;
	width: 100%;
	transform-origin: 0%;
	background: currentColor;
	transition: transform .3s;
	position: absolute;
	top: 90%
}

.frame a:not(.frame__title-back):hover:before {
	transform-origin: 100%;
	transform: scaleX(0)
}

.frame__title {
	grid-area: title;
	display: flex;
}

.frame__title-main {
	margin: 0;
	font-size: .75rem;
	font-weight: 400;
}

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

.frame__title-back span {
	display: none
}

.frame__title-back svg {
	fill: currentColor
}

.frame__prev {
	grid-area: prev
}

.frame__demos {
	flex-wrap: wrap;
	grid-area: nav;
	justify-self: stretch;
	gap: 1.5rem;
	display: flex;
}

.prime {
	grid-area: 1 / 1 / 2 / 2;
	padding: 10rem var(--padding-ver) 0;
	position: relative;
	z-index: 30;
	display: flex;
	flex-direction: column;
}

.demo-2 .prime {
	will-change: clip-path;
}

.content-open .prime {
	pointer-events: none;
}

.intro {
	grid-column: 1 / span 2;
	grid-row: 1 / span 3;
	display: inline-flex;
	gap: 0;
	line-height: 1.2;
	flex-wrap: wrap;
	font-size: 7.5vw;
	letter-spacing: -0.25vw;
	align-items: center;
	align-content: center;
	font-weight: 100;
	font-family: articulat-cf, sans-serif;
	font-weight: 100;
	font-style: normal;
}

.intro .oh__inner {
	padding: 0 1vw;
}

.intro em.oh__inner {
	padding: 0 2vw;
}

.intro .image-wrap:first-child {
	padding-left: 2vw;
}

.intro em {
	font-family: miller-banner, serif;
	font-weight: 300;
	font-style: italic;
}

.intro--close {
	pointer-events: none;
}

.image-wrap {
	width: 11vw;
	aspect-ratio: 1.75;
	position: relative;
}

.image-wrap .image {
	width: 100%;
	height: 100%;
}

.image {
	overflow: hidden;
	position: relative;
	display: grid;
	place-items: center;
	will-change: transform;
}

.prime .image--bg {
	width: 100%;
	height: 100%;
	position: absolute;
	top: 0;
	left: 0;
}

.image__inner {
	width: 100%;
	height: 100%;
	background-size: cover;
	background-position: 50% 50%;
}

.meta__title {
	font-size: clamp(1rem,5vw,2.25rem);
	font-family: miller-banner, serif;
	font-weight: 300;
	font-style: italic;
	margin: 0;
	display: flex;
	justify-content: flex-end;
}

.meta__title .oh__inner {
	padding: 0 0.25rem;
}

.nav-wrap {
	margin-top: auto;
	padding: var(--padding-hor) 0;
	border-top: 1px solid var(--color-text-alt);
	position: relative;
	display: grid;
	grid-template-columns: 1fr 1fr;
	grid-template-areas: 'logo social' 'nav nav';
	align-items: center;
	will-change: transform;
}

.demo-2 .nav-wrap {
	padding-bottom: calc(var(--padding-hor) + 20px);
}

.logo {
	grid-area: logo;
}

.logo__years {
	font-size: 0.75rem;
	line-height: 1;
}

.logo__title {
	text-transform: uppercase;
	margin: 0;
	font-size: 3rem;
	line-height: 1;
	font-family: articulat-cf, sans-serif;
	font-weight: 100;
}

.nav {
	text-transform: uppercase;
	grid-area: nav;
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
	padding-top: 2rem;
}

.nav__item {
	color: var(--color-text-alt);
	display: flex;
	flex-direction: column;
	pointer-events: none;
}

.nav__item--active {
	color: var(--color-text);
	pointer-events: auto;
}

.social {
	grid-area: social;
	display: flex;
	gap: 1rem;
	justify-self: end;
}

.content {
	position: relative;
	grid-area: 1 / 1 / 2 / 2;
	display: grid;
	height: 100%;
	grid-template-rows: repeat(5,min-content);
	grid-template-columns: 100%;
	align-content: space-between;
	justify-items: center;
	padding: 0.5rem;
}

.content__item {
	width: 100%;
	display: grid;
	grid-template-columns: 1fr 215px;
	grid-template-rows: 130px;
	grid-column-gap: 4vw;
	align-items: center;
	justify-items: end;
	z-index: 20;
	position: relative;
}

.content__item:last-child {
	z-index: 1;
}

.content__item .image {
	grid-column: 2;
}

.content .image {
	width: 215px;
	height: 100%;
}

.title-wrap {
	opacity: 0;
	display: grid;
	grid-template-rows: auto auto;
	grid-template-columns: auto auto;
	grid-template-areas: 'back ...' 'number ...' '... title';
}

.content__item--current .title-wrap {
	opacity: 1;
}

.title-wrap .oh__inner {
	transform: translateY(100%);
}

.back {
	grid-area: back;
	stroke: var(--color-link);
	cursor: pointer;
	fill: none;
}

.back svg {
	pointer-events: none;
}

.content .back {
	opacity: 0;
}

.number {
	grid-area: number;
	font-size: 0.65rem;
	justify-self: end;
}

.title {
	grid-area: title;
	font-family: miller-banner, serif;
	font-weight: 300;
	font-style: italic;
	margin: 0;
	font-size: 4vw;
	text-transform: lowercase;
	white-space: nowrap;
}

.title .oh__inner {
	padding: 0 0.5vw;
}

.grid {
	grid-area: 1 / 1 / -1 / -1;
	width: 100%;
	max-width: 1100px;
	padding: var(--padding-ver) var(--padding-hor);
	grid-gap: 1rem;
	max-height: 100vh;
	display: grid;
	grid-template-columns: repeat(7,1fr);
	grid-template-rows: repeat(7,1fr);
	align-content: center;
	margin: auto;
}

.grid__item {
	width: 100%;
	max-width: 145px;
	aspect-ratio: 145/88;
	will-change: transform;
	position: relative;
	overflow: hidden;
	display: grid;
	place-items: center;
}

.grid__item:nth-child(1) {
    grid-area: 2/1
}

.grid__item:nth-child(2) {
    grid-area: 3/1
}

.grid__item:nth-child(3) {
    grid-area: 4/2
}

.grid__item:nth-child(4) {
    grid-area: 3/3
}

.grid__item:nth-child(5) {
    grid-area: 7/3
}

.grid__item:nth-child(6) {
    grid-area: 5/3
}

.grid__item:nth-child(7) {
    grid-area: 5/4
}

.grid__item:nth-child(8) {
    grid-area: 6/4
}

.grid__item:nth-child(9) {
    grid-area: 1/5
}

.grid__item:nth-child(10) {
    grid-area: 3/5
}

.grid__item:nth-child(11) {
    grid-area: 4/5
}

.grid__item:nth-child(12) {
    grid-area: 2/6
}

.grid__item:nth-child(13) {
    grid-area: 5/6
}

.grid__item:nth-child(14) {
    grid-area: 6/7
}

.grid__item .image {
	width: 100%;
	height: 100%;
}

.view {
	cursor: pointer;
	stroke: #fff;
	text-align: left;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	border: 1px solid #fff;
	width: 14rem;
 	aspect-ratio: 1;
 	text-align: center;
}

.view__text {
	text-transform: uppercase;
}

.view svg {
	transform: scale(-1,-1);
	margin-top: 0.5rem;
}

.cursor {
	display: none;
}

@media screen and (min-width: 53em) {
	:root {
		--padding-ver: 2.5rem;
		--padding-hor: 1rem;
	}
	body {
		height: 100%;
		overflow: hidden;
	}
	.frame {
		grid-gap: 2rem;
		grid-template-areas: "title prev nav sponsor";
		grid-template-columns: auto auto 1fr auto;
		grid-template-rows: auto;
		grid-area: 1 / 1 / -1 / -1;
		align-content: space-between;
	}
	.content__item {
		grid-template-columns: 1fr 215px 1fr;
	}
	.title-wrap {
		opacity: 1;
	}
	.frame__demos {
		justify-self: end;
		padding-right: 5vw;
	}
	.prime {
		padding-top: 6rem;
	}
	.nav-wrap {
		grid-template-columns: 20% 1fr 10% 10%;
		grid-template-areas: 'logo nav ... social';
	}
	.nav {
		padding: 0;
		gap: 3vw;
		flex-wrap: wrap;
		justify-content: center;
	}
	.nav__item::after {
		content: '...';
		display: block;
		font-weight: 400;
		font-size: 1.15rem;
		text-align: center;
		line-height: 0.9;
	}
}

@media (any-pointer:fine) {
	.cursor {
		position: fixed;
		top: 0;
		left: 0;
		display: block;
		pointer-events: none;
		z-index: 10000;
	}

	.cursor__inner {
		fill: none;
		stroke: var(--cursor-stroke);
		stroke-width: 1.3px;
	}

	.no-js .cursor {
		display: none;
	}
}

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>Inline Layout Switch | Demo 1 | Codrops</title>
		<meta name="description" content="Two ideas for page transitions from an inline view to an image column or grid." />
		<meta name="keywords" content="gsap flip, page transition, animation, frontend, layout" />
		<meta name="author" content="Codrops" />
		<link rel="shortcut icon" href="favicon.ico">
		<link rel="stylesheet" href="https://use.typekit.net/fyt6bvn.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">Inline Layout Switch</h1> 
					<a aria-label="Back to the article" class="frame__title-back" href="https://tympanus.net/codrops/?p=65913"> 
						<span class="oh__inner">Back to the article</span> 
						<svg width="16px" height="16px" 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/3DTypeEffects">Previous demo</a>
				<nav class="frame__demos">
					<span class="frame__demos-item">Demo I</span>
					<a class="frame__demos-item" href="index2.html">Demo II</a>
				</nav>
			</div>
			<div class="content">
				<div class="content__item">
					<div class="title-wrap">
						<span class="number oh"><span class="oh__inner">01</span></span>
						<h3 class="title oh"><span class="oh__inner">Grand Belle</span></h3>
					</div>
				</div>
				<div class="content__item">
					<div class="title-wrap">
						<span class="number oh"><span class="oh__inner">02</span></span>
						<h3 class="title oh"><span class="oh__inner">Fiction Freak</span></h3>
					</div>
				</div>
				<div class="content__item content__item--current">
					<div class="title-wrap">
						<button class="back unbutton"><svg width="50" height="9" viewBox="0 0 50 9"><path vector-effect="non-scaling-stroke" d="m0 4.5 5-3m-5 3 5 3m45-3h-77"></path></svg></button>
						<span class="number oh"><span class="oh__inner">03</span></span>
						<h3 class="title oh"><span class="oh__inner">Frankie Low</span></h3>
					</div>
				</div>
				<div class="content__item">
					<div class="title-wrap">
						<span class="number oh"><span class="oh__inner">04</span></span>
						<h3 class="title oh"><span class="oh__inner">Opion Release</span></h3>
					</div>
				</div>
				<div class="content__item">
					<div class="title-wrap">
						<span class="number oh"><span class="oh__inner">05</span></span>
						<h3 class="title oh"><span class="oh__inner">War Herd</span></h3>
					</div>
				</div>
			</div>
			<div class="prime">
				<div class="image image--bg"><div class="image__inner" style="background-image:url(img/bg.jpg)"></div></div>
				<div class="intro">
					<div class="image-wrap">
						<div class="image">
							<div class="image__inner" style="background-image:url(img/1.jpg)"></div>
						</div>
					</div>
					<span class="oh"><span class="oh__inner">She</span></span>
					<span class="oh"><em class="oh__inner">who</em></span> 
					<div class="image-wrap">
						<div class="image">
							<div class="image__inner" style="background-image:url(img/2.jpg)"></div>
						</div>
					</div>
					<span class="oh"><span class="oh__inner">conquers</span></span> 
					<span class="oh"><em class="oh__inner">herself</em></span>
					<span class="oh"><span class="oh__inner">is</span></span> 
					<span class="oh"><span class="oh__inner">the</span></span>
					<span class="oh"><em class="oh__inner">mightiest</em></span>
					<div class="image-wrap">
						<div class="image">
							<div class="image__inner" style="background-image:url(img/3.jpg)"></div>
						</div>
					</div>
					<span class="oh"><span class="oh__inner">warrioress.</span></span>
					<div class="image-wrap">
						<div class="image">
							<div class="image__inner" style="background-image:url(img/4.jpg)"></div>
						</div>
					</div>
				</div>
				<div class="meta">
					<h3 class="meta__title">
						<span class="oh"><span class="oh__inner">Mia</span></span>
						<span class="oh"><span class="oh__inner">Le</span></span> 
						<span class="oh"><span class="oh__inner">Sage</span></span>
					</h3>
				</div>
				<footer class="nav-wrap">
					<div class="logo">
						<span class="logo__years">1998 - 2022</span>
						<h2 class="logo__title">N&K</h2>
					</div>
					<nav class="nav">
						<a class="nav__item">The Studio</a>
						<a class="nav__item nav__item--active">All Projects</a>
						<a class="nav__item">Work with us</a>
					</nav>
					<nav class="social">
						<a class="social__item" href="https://twitter.com/codrops">tw</a>
						<a class="social__item" href="https://www.instagram.com/codropsss/">in</a>
						<a class="social__item" href="https://www.facebook.com/codrops/">fb</a>
					</nav>
				</footer>
			</div>		
		</main>
		<script type="module" src="js/index.js"></script>
		<script src="https://tympanus.net/codrops/adpacks/cda_sponsor.js"></script>
	</body>
</html>
함께 쓰는 파일 8개 보기
src/index2.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>Inline Layout Switch | Demo 2 | Codrops</title>
		<meta name="description" content="Two ideas for page transitions from an inline view to an image column or grid." />
		<meta name="keywords" content="gsap flip, page transition, animation, frontend, layout" />
		<meta name="author" content="Codrops" />
		<link rel="shortcut icon" href="favicon.ico">
		<link rel="stylesheet" href="https://use.typekit.net/fyt6bvn.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-2 loading">
		<main>
			<div class="frame">
				<div class="frame__title"> 
					<h1 class="frame__title-main">Inline Layout Switch</h1> 
					<a aria-label="Back to the article" class="frame__title-back" href="https://tympanus.net/codrops/?p=65913"> 
						<span class="oh__inner">Back to the article</span> 
						<svg width="16px" height="16px" 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/3DTypeEffects">Previous demo</a>
				<nav class="frame__demos">
					<a class="frame__demos-item" href="index.html">Demo I</a>
					<span class="frame__demos-item">Demo II</span>
				</nav>
			</div>
			<div class="grid">
				<div class="grid__item">
					<button class="back unbutton"><svg width="100" height="18" viewBox="0 0 50 9"><path vector-effect="non-scaling-stroke" d="m0 4.5 5-3m-5 3 5 3m45-3h-77"></path></svg></button>
				</div>
				<div class="grid__item">
					<div class="image">
						<div class="image__inner" style="background-image:url(img/1.jpg)"></div>
					</div>
				</div>
				<div class="grid__item">
					<div class="image">
						<div class="image__inner" style="background-image:url(img/2.jpg)"></div>
					</div>
				</div>
				<div class="grid__item">
					<div class="image">
						<div class="image__inner" style="background-image:url(img/3.jpg)"></div>
					</div>
				</div>
				<div class="grid__item">
					<div class="image">
						<div class="image__inner" style="background-image:url(img/4.jpg)"></div>
					</div>
				</div>
				<div class="grid__item">
					<div class="image">
						<div class="image__inner" style="background-image:url(img/11.jpg)"></div>
					</div>
				</div>
				<div class="grid__item">
					<div class="image">
						<div class="image__inner" style="background-image:url(img/9.jpg)"></div>
					</div>
				</div>
				<div class="grid__item">
					<div class="image">
						<div class="image__inner" style="background-image:url(img/8.jpg)"></div>
					</div>
				</div>
				<div class="grid__item">
					<div class="image">
						<div class="image__inner" style="background-image:url(img/7.jpg)"></div>
					</div>
				</div>
				<div class="grid__item">
					<div class="image">
						<div class="image__inner" style="background-image:url(img/6.jpg)"></div>
					</div>
				</div>
				<div class="grid__item">
					<div class="image">
						<div class="image__inner" style="background-image:url(img/10.jpg)"></div>
					</div>
				</div>
				<div class="grid__item">
					<div class="image">
						<div class="image__inner" style="background-image:url(img/12.jpg)"></div>
					</div>
				</div>
				<div class="grid__item">
					<div class="image">
						<div class="image__inner" style="background-image:url(img/13.jpg)"></div>
					</div>
				</div>
				<div class="grid__item">
					<div class="image">
						<div class="image__inner" style="background-image:url(img/14.jpg)"></div>
					</div>
				</div>
			</div>
			<div class="prime">
				<div class="image image--bg"><div class="image__inner" style="background-image:url(img/bg2.jpg)"></div></div>
				<div class="intro">
					<div class="image-wrap">
						<div class="image">
							<div class="image__inner" style="background-image:url(img/14.jpg)"></div>
						</div>
					</div>
					<span class="oh"><span class="oh__inner">She</span></span>
					<span class="oh"><em class="oh__inner">who</em></span> 
					<div class="image-wrap">
						<div class="image">
							<div class="image__inner" style="background-image:url(img/13.jpg)"></div>
						</div>
					</div>
					<span class="oh"><span class="oh__inner">conquers</span></span> 
					<span class="oh"><em class="oh__inner">herself</em></span>
					<span class="oh"><span class="oh__inner">is</span></span> 
					<span class="oh"><span class="oh__inner">the</span></span>
					<span class="oh"><em class="oh__inner">mightiest</em></span>
					<div class="image-wrap">
						<div class="image">
							<div class="image__inner" style="background-image:url(img/12.jpg)"></div>
						</div>
					</div>
					<span class="oh"><span class="oh__inner">warrioress.</span></span>
					<div class="image-wrap">
						<div class="image">
							<div class="image__inner" style="background-image:url(img/10.jpg)"></div>
						</div>
					</div>
				</div>
				<div class="meta">
					<h3 class="meta__title">
						<span class="oh"><span class="oh__inner">Mia</span></span>
						<span class="oh"><span class="oh__inner">Le</span></span> 
						<span class="oh"><span class="oh__inner">Sage</span></span>
					</h3>
				</div>
				<footer class="nav-wrap">
					<div class="logo">
						<span class="logo__years">1998 - 2022</span>
						<h2 class="logo__title">N&K</h2>
					</div>
					<nav class="nav">
						<a class="nav__item">The Studio</a>
						<a class="nav__item nav__item--active">All Projects</a>
						<a class="nav__item">Work with us</a>
					</nav>
					<nav class="social">
						<a class="social__item" href="https://twitter.com/codrops">tw</a>
						<a class="social__item" href="https://www.instagram.com/codropsss/">in</a>
						<a class="social__item" href="https://www.facebook.com/codrops/">fb</a>
					</nav>
				</footer>
			</div>
		</main>
	</body>
	<script type="module" src="js/index2.js"></script>
	<script src="https://tympanus.net/codrops/adpacks/cda_sponsor.js"></script>
</html>
src/js/contentItem.js
파일 저장

/**
 * Class representing a content item element (.content__item)
 */
 export class ContentItem {
	// DOM elements
	DOM = {
		// main element (.content__item)
		el: null,
        // back (.back)
        back: null,
        // number (.number > .oh__inner)
        number: null,
        // title (.title > .oh__inner)
        title: null,
	};
	
	/**
	 * Constructor.
	 * @param {Element} DOM_el - main element (.content__item)
	 */
	constructor(DOM_el) {
		this.DOM.el = DOM_el;
        this.DOM.back = this.DOM.el.querySelector('.back');
        this.DOM.number = this.DOM.el.querySelector('.number > .oh__inner');
        this.DOM.title = this.DOM.el.querySelector('.title > .oh__inner');
	}

    isCurrent() {
        return this.DOM.el.classList.contains('content__item--current');
    }
}
src/js/index.js
파일 저장

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

// body
const body = document.body;

// .content__item elements
const contentItems = [...document.querySelectorAll('.content__item')];

// For the purposes of the demo (which is to showcase the animation only) we'll hardcode the following.
const contentItemsArr = [];
contentItems.forEach(item => contentItemsArr.push(new ContentItem(item)));
const contentItemCurrent = contentItemsArr.find(item => item.isCurrent());

// .image elements
const images = [...document.querySelectorAll('.image')];

// total
const totalImages = images.length;

// .prime
const prime = document.querySelector('.prime');

// all .image-wrap. This is the original position af an image element bofore moving to the content item (Flip animation)
const imageWraps = [...prime.querySelectorAll('.image-wrap')];

// View all projects link
const viewAllProjects = prime.querySelector('.nav__item--active');

// Quote texts that will get hidden when showing the images carousel
const texts = [...prime.querySelectorAll('.oh > .oh__inner')];

// .nav-wrap element that moves up/down when toggling the view
const navWrap = document.querySelector('.nav-wrap');

let isAnimating;

// Animation / Show images carousel
const showImages = () => {
    
    if ( isAnimating ) return;
    isAnimating = true;

    // Save current state of the images
    const flipstate = Flip.getState(images);
    
    const tl = gsap.timeline({
        onComplete: () => {
            // pointer events
            body.classList.add('content-open');
            isAnimating = false;
        },
        defaults: {
            duration: 1.2,
            ease: 'power4.inOut',
        }
    })
    .addLabel('start', 0)
    .add(() => {
        // Append each image to each content item
        for (const [pos, contentItem] of contentItems.entries()) {
            contentItem.appendChild(images[totalImages-1-pos]);
        }
        
        // flip them
        Flip.from(flipstate, {
            duration: 1,
            ease: 'expo.inOut',
            absolute: true,
            simple: true,
            /*
            spin: pos => {
                if (pos === totalImages-1) return 0;

                return pos%2 ? 1 : -1;
            },
            */
            stagger: -0.06
        });
    }, 'start+=0.15');

    for (const text of texts) {
        const xy = gsap.utils.random(0,1,1);

        tl.to(text, {
            xPercent: xy ? gsap.utils.random(0,1,1)%2 ? -100 : 100 : 0,
            yPercent: xy ? 0 : gsap.utils.random(0,1,1)%2 ? -100 : 100
        }, 'start');
    }

    tl
    .to(navWrap, {
        yPercent: 120 // a bit more than 100 so it doesn't end right below the viewport
    }, 'start')
    .to([contentItemCurrent.DOM.number, contentItemCurrent.DOM.title], {
        y: 0
    }, 'start+=0.3')
    .to(contentItemCurrent.DOM.back, {
        opacity: 1
    }, 'start+=0.3');
    
}

// Back animation
contentItemCurrent.DOM.back.addEventListener('click', () => {
    
    if ( isAnimating ) return;
    isAnimating = true;

    // Save current state of the images
    const flipstate = Flip.getState(images);

    const tl = gsap.timeline({
        onComplete: () => {
            body.classList.remove('content-open');
            isAnimating = false;
        },
        defaults: {
            duration: 1.2,
            ease: 'power4.inOut',
        }
    })
    .addLabel('start', 0)
    .to([contentItemCurrent.DOM.number, contentItemCurrent.DOM.title], {
        y: '100%'
    }, 'start')
    .to(contentItemCurrent.DOM.back, {
        opacity: 0
    }, 'start')
    .to(navWrap, {
        yPercent: 0
    }, 'start')
    .to(texts, {
        xPercent: 0,
        yPercent: 0
    }, 'start')
    .add(() => {
        // Put images in their original positions
        prime.prepend(images[0]);
        for (const [pos, imageWrap] of imageWraps.entries()) {
            imageWrap.appendChild(images[pos+1]);
        }
        
        // flip them
        Flip.from(flipstate, {
            duration: 1,
            ease: 'expo.inOut',
            absolute: true,
            simple: true,
            stagger: 0.06
        });
    }, 'start+=0.15');

});

viewAllProjects.addEventListener('click', () => showImages());

for (const item of contentItemsArr) {
    if ( !item.isCurrent() ) {
        item.DOM.el.addEventListener('mouseenter', () => {
            gsap.to([item.DOM.number, item.DOM.title], {
                y: 0
            });
        });
        item.DOM.el.addEventListener('mouseleave', () => {
            gsap.to([item.DOM.number, item.DOM.title], {
                y: '100%'
            });
        });
    }
}

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

import { preloadImages, getInitialPosition, getDistance, map } from './utils';
import { gsap } from 'gsap';

// body
const body = document.body;

// .grid__item
const gridItems = [...document.querySelectorAll('.grid__item')];

// .prime (clip path animation will be on the element)
const prime = document.querySelector('.prime');

// image .image--bg
const imageBg = prime.querySelector('.image--bg');

// View all projects link
const viewAllProjects = prime.querySelector('.nav__item--active');

// back button
const back = document.querySelector('.grid__item > .back')

let isAnimating;

// Animation / Show images carousel
const showImages = () => {
    
    if ( isAnimating ) return;
    isAnimating = true;

    const tl = gsap.timeline({
        onComplete: () => {
            // pointer events
            body.classList.add('content-open');
            isAnimating = false;
        },
        defaults: {
            duration: 1,
            ease: 'expo.inOut',
        }
    })
    .addLabel('start', 0)

    for (const gridItem of gridItems) {
        const {x,y} = getInitialPosition(gridItem);
        const delay = map(getDistance(gridItem), 0, 1000, 0, 0.4);

        tl.set(gridItem, {
            x: x,
            y: y,
            opacity: 0
        }, 'start')
        .to(gridItem, {
            x: 0,
            y: 0,
            delay: delay,
            opacity: 1
        }, 'start+=0')
    }
    
    tl.to(imageBg, {
        scale: 1.1
    }, 'start')
    .to(prime, {
        startAt: {clipPath : 'polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)'},
        clipPath: 'polygon(50% 50%, 50% 50%, 50% 50%, 50% 50%)'
    }, 'start')
    
}

// Back animation
back.addEventListener('click', () => {
    
    if ( isAnimating ) return;
    isAnimating = true;

    const tl = gsap.timeline({
        onComplete: () => {
            body.classList.remove('content-open');
            isAnimating = false;
        },
        defaults: {
            duration: 1,
            ease: 'expo.inOut',
        }
    })
    .addLabel('start', 0)
    .to(prime, {
        startAt: {clipPath : 'polygon(50% 50%, 50% 50%, 50% 50%, 50% 50%)'},
        clipPath: 'polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)'
    }, 'start+=0.4')
    .to(imageBg, {
        startAt: {scale: 1.4},
        scale: 1
    }, 'start+=0.4');

    for (const gridItem of gridItems) {
        const {x,y} = getInitialPosition(gridItem);
        const delay = map(getDistance(gridItem), 0, 1000, 0.4, 0);

        tl.to(gridItem, {
            x: x,
            y: y,
            delay: delay,
            opacity: 0
        }, 'start')
    }

});

viewAllProjects.addEventListener('click', () => showImages());

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

const imagesLoaded = require('imagesloaded');

/**
 * Map number x from range [a, b] to [c, d] 
 * @param {Number} x - changing value
 * @param {Number} a 
 * @param {Number} b
 * @param {Number} c
 * @param {Number} d
 */
 const map = (x, a, b, c, d) => (x - a) * (d - c) / (b - a) + c;

/**
 * Distance from the element's center point to the center of the page 
 * @param {Element} element 
 * @returns 
 */
const getDistance = element => {
    const elCenter = {x: element.offsetLeft + element.offsetWidth/2, y: element.offsetTop + element.offsetHeight/2};
    return Math.hypot(elCenter.x - window.innerWidth/2, elCenter.y - window.innerHeight/2);
}

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

/** 
 * Calculates the position of an element when the element is [distanceDifference]px more far from the center of the page than it was previously
 * @param {Element} element
 * @param {Number} distanceDifference - The distance the element will have from the center
 * @returns {JSON} the x,y translation values
 */
 const getInitialPosition = (element, distanceDifference = 400) => {
    const winsize = {width: window.innerWidth, height: window.innerHeight};
    const elCenter = {x: element.offsetLeft + element.offsetWidth/2, y: element.offsetTop + element.offsetHeight/2};
    const angle = Math.atan2(Math.abs(winsize.height/2 - elCenter.y), Math.abs(winsize.width/2 - elCenter.x));

    let x = Math.abs(Math.cos(angle) * distanceDifference);
    let y = Math.abs(Math.sin(angle) * distanceDifference);

    return {
        x: elCenter.x < winsize.width/2 ? x*-1 : x,
        y: elCenter.y < winsize.height/2 ? y*-1 : y
    };
};

export {
    map,
    getDistance,
    getInitialPosition,
    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.