Codrops 원본

Image Trail Animation for an Intro

섹션 · MIT

섹션 더 보기
ORIGINAL PREVIEW
Image Trail Animation for an Intro 정적 미리보기

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

큰 화면으로 보기 새 탭

SOURCE FILES

원본 코드 읽기

11개 파일

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

src/css/base.css
파일 저장

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

:root {
	font-size: 17px;
}

html, body {
	height: 100vh;
	overflow: hidden;
}

body {
	margin: 0;
	--color-text: #fff;
	--color-title: #dbb59b;
	--color-bg: #161a19;
	--color-link: #7f9993;
	--color-link-hover: #fff;
	--color-menu: #7f9993;
	--img-ratio: 1.5;
	font-weight: 300;
	color: var(--color-text);
	background: var(--color-bg);
	font-family: acumin-pro, -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

body::after {
	z-index: 1000;
	content: '';
	pointer-events: none;
	width: 100vw;
	height: 100vh;
	position: fixed;
	top: 0;
	left: 0;
	background: url(../img/shadow.png) no-repeat 100% 0%;
	background-size: cover;
	animation: move 7s infinite alternate 2s;
	transform-origin: 100% 0%;
}

@keyframes move {
	to {
		transform: scaleX(1.1);
	}
}

/* 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;
	white-space: nowrap;
	overflow: hidden;
	position: relative;
}

a::before {
	content: '';
	height: 1px;
	width: 100%;
	background: currentColor;
	position: absolute;
	top: 95%;
	transition: transform 0.3s;
	transform-origin: 0% 50%;
}

a:hover::before {
	transform: scaleX(0);
	transform-origin: 100% 50%;
}

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 {
	overflow: hidden;
}

.line {
	transform-origin: 0 50%;
	padding-bottom: 0.15rem;
	white-space: nowrap;
	will-change: transform;
}

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

.unbutton:focus {
	outline: none;
}

main {
	padding: 1rem;
	display: grid;
	height: 100%;
	grid-template-columns: 1fr 250px;
	grid-template-rows: 25% 25% 1fr;
	grid-template-areas: 'logo menu' '... ...' 'button-enter button-enter' 'frame frame';
}

.frame {
	grid-area: frame;
	padding-bottom: 0.5rem;
	position: relative;
	z-index: 200;
}

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

.frame__links a:not(:last-child) {
	margin-right: 1rem;
}

.logo {
	margin: 0;
	font-size: 2.45rem;
	grid-area: logo;
	font-family: kudryashev-d-excontrast-sans, sans-serif;
	font-weight: 300;
	display: grid;
	justify-self: start;
	line-height: 1;
	color: var(--color-title);
}

.logo__layer {
	grid-area: 1 / 1 / 2 / 2;
	transition: all ease-out 0.5s;
}

.show .logo__layer--1 {
	opacity: 0.1;
}

.show .logo__layer--2 {
	opacity: 0.3;
	transform: translateX(50%);
}

.show .logo__layer--3 {
	transform: translateX(100%);
}

.button-menu {
	z-index: 100;
	margin: 0.5rem 1.5rem;
	grid-area: menu;
	justify-self: end;
	width: 1.65rem;
	height: 0.65rem;
	color: var(--color-menu);
	border-top: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	opacity: 0.5;
	align-self: start;
	cursor: not-allowed;
}

.intro-progress {
	grid-area: logo;
	justify-self: start;
	align-self: start;
	font-size: 10vw;
	width: 4ch;
	line-height: 0.5;
	font-weight: 400;
	color: var(--color-title);
}

.intro-image {
	position: relative;
	background-size: 100%;
	background-repeat: no-repeat;
	grid-area: 1 / 1 / -1 / -1;
	justify-self: end;
	--img-height: 260px;
	height: var(--img-height);
	width: calc( 1 / var(--img-ratio) * var(--img-height));
}

.intro-content__image .intro-image {
	--img-height: 360px;
}

.trail {
	position: relative;
	display: grid;
	place-items: center;
}

.no-js .trail {
	width: 100%;
	height: 100%;
	background-size: 100%;
}

.trail__img,
.trail__text {
	position: relative;
	will-change: transform;
	grid-area: 1 / 1 / 2 / 2;
}

.trail__img {
	width: 100%;
	height: 100%;
}

.intro-content {
	height: 100%;
	overflow: hidden;
	grid-area: 1 / 1 / -1 / -1;
	display: grid;
	grid-template-columns: 100%;
	justify-items: center;
	grid-template-rows: 4rem min-content min-content 1rem auto 1fr; 
	grid-template-areas: '...' 'title-up' 'title-down' '...' 'image' '...';
}

.intro-content__title {
	font-size: 25vh;
	font-size: clamp(1.5rem,22vh,14vw);
	line-height: 0.9;
	position: relative;
	color: var(--color-title);
	font-weight: 400;
	white-space: nowrap;
	align-self: end;
	will-change: transform;
}

.intro-content__title em {
	font-weight: 400;
	font-style: italic;
}

.intro-content__title--up {
	font-family: kudryashev-d-excontrast-sans, sans-serif;
	font-weight: 300;
	grid-area: title-up;
	align-self: end;
	opacity: 0;
}

.intro-content__title--up .trail__text {
	transform: translateY(-14vh);
}

.intro-content__title--down {
	text-transform: uppercase;
	grid-area: title-down;
	opacity: 0;
}

.intro-content__title--down .trail__text {
	transform: translateY(18vh);
}

.intro-content__image {
	grid-area: image;
	align-self: end;
}

.button-enter {
	position: relative;
	z-index: 200;
	grid-area: button-enter;
	align-self: center;
	justify-self: center;
	color: inherit;
	background: transparent;
	width: 100px;
	height: 100px;
	display: grid;
	place-items: center;
	border-radius: 50%;
	overflow: hidden;
	cursor: pointer;
	border: 1px solid currentColor;
	align-self: start;
}

.button-enter.hide {
	pointer-events: none;
}

.button-enter span {
	pointer-events: none;
	cursor: pointer;
	position: relative;
	display: block;
	width: 100%;
	height: 100%;
	display: grid;
	place-items: center;
	color: #fff;
	font-weight: 400;
	transform: translateY(1rem);
	transition: color, transform 0.3s;
}

.button-enter:hover span,
.button-enter:focus-visible span {
	color: #000;
	transform: translateY(0);
}

.button-enter::before {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 100px;
	height: 100px;
	margin: -50px 0 0 -50px;
	background: #fff;
	transform: translateY(100%);
	transition: transform 0.3s;
}

.button-enter:hover::before,
.button-enter:focus-visible::before  {
	transform: translateY(0%);
}

.js .logo,
.js .button-menu,
.js .button-enter {
	opacity: 0;
}

.js .logo.show,
.js .button-menu.show,
.js .button-enter.show {
	transition: opacity ease-out 0.5s;
	opacity: 1;
}

.js .button-enter.show {
	transition: opacity ease-in-out 1.5s;
}

.content {
	pointer-events: none;
	height: 100%;
	grid-area: 1 / 1 / -1 / -1;
	display: grid;
	padding: 0 1rem;
	grid-template-columns: 31% 31% 31%;
	grid-column-gap: 3.5%;
	grid-template-rows: 4rem min-content min-content 2rem auto auto;
	grid-template-areas: '... ... ...'
						'content-title-up content-title-up content-title-up'
						'content-title-down content-title-down content-title-down'
						'... ... ...'
						'content-about content-about content-about'
						'content-img-1 content-img-2 content-img-3';
}

.content__title {
	position: relative;
}

.content__title .intro-content__title {
	font-size: clamp(2rem, 10vh, 8vw);
	width: min-content;
	grid-column: 1 / span 2;
}

.content__title--up {
	z-index: 1;
	grid-area: content-title-up;
	
}

.content__title--down {
	z-index: 3;
	grid-area: content-title-down;
}

.content__about {
	position: relative;
	z-index: 100;
	grid-area: content-about;
	display: flex;
	flex-direction: column;
	font-size: 1.3rem;
	line-height: 1.1;
	opacity: 0;
}

.content__about-title {
	font-style: italic;
	margin: 0 7vw 0 0;
}

.content__about p {
	margin: 0 0 1rem;
}

.content__image {
	position: relative;
	z-index: 2;
	display: flex;
	align-items: flex-end;
	margin-bottom: -20vh;
}

.content__image--1 {
	grid-area: content-img-1;
}

.content__image--2 {
	grid-area: content-img-2;
}

.content__image--3 {
	grid-area: content-img-3;
}

.content__image-inner,
.content__image .intro-image {
	background-position: 50% 0%;
	background-size: cover;
	width: 100%;
	height: 100%;
	opacity: 0;
	border-radius: 20vw 20vw 0 0;
	will-change: opacity, transform, border-radius;
}

@media screen and (min-width: 53em) {
	main {
		padding: 2.5rem 1rem 0;
		grid-column-gap: 5vw;
		grid-template-columns: 30vw 1fr 30vw;
		grid-template-rows: auto 50% 1fr auto;
		grid-template-areas: 'logo ... menu' 
							'... ... ...'
							'... button-enter ...' 
							'frame frame frame';
	}
	.intro-content {
		grid-template-rows: 32% 15% 35% 18%; 
		grid-template-areas: 'title-up' 'title-down' 'image' '...';
	}
	.intro-image {
		--img-height: 45vh;
	}

	.intro-content__image .intro-image {
		--img-height: 53vh;
	}
	.content {
		grid-template-rows: 20% 10vh 10vh auto auto;
		grid-template-areas: '... ... ...'
						'content-title-up content-about content-about'
						'content-title-down content-about content-about'
						'content-img-1 content-img-2 content-img-3';
	}
	.content__title .intro-content__title {
		grid-column: 1 / span 2;
	}
	.content__about {
		flex-direction: row;
		grid-row: 2 / span 2;
		justify-self: end;
		max-width: 440px;
	}
	.content__image-inner,
	.content__image .intro-image {
		height: 50vh;
		border-radius: 20vw 20vw 0 0;
	}
	.button-enter {
		align-self: center;
	}
	.frame {
		display: grid;
		width: 100%;
		grid-template-areas: 'title links sponsor';
		grid-template-columns: auto auto 1fr;
	}

	.frame__title {
		grid-area: title;
	}

	.frame__links {
		grid-area: links;
	}

	.frame__links {
		margin-left: 5vw;
	}
}
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>Intro Image Trail Animation | Codrops</title>
		<meta name="description" content="An intro animation with various animation stages." />
		<meta name="keywords" content="intro animation, gsap, flip plugin, image trail, loading" />
		<meta name="author" content="Codrops" />
		<link rel="shortcut icon" href="favicon.ico">
		<link rel="stylesheet" href="https://use.typekit.net/ubi4yxd.css">
		<link rel="stylesheet" type="text/css" href="css/base.css" />
		<script>document.documentElement.className="js";var supportsCssVars=function(){var e,t=document.createElement("style");return t.innerHTML="root: { --tmp-var: bold; }",document.head.appendChild(t),e=!!(window.CSS&&window.CSS.supports&&window.CSS.supports("font-weight","var(--tmp-var)")),t.parentNode.removeChild(t),e};supportsCssVars()||alert("Please view this demo in a modern browser that supports CSS Variables.");</script>
		<script src="//tympanus.net/codrops/adpacks/analytics.js"></script>
	</head>
	<body class="loading">
		<main>
			<div class="frame">
				<h1 class="frame__title">Intro Image Trail Animation</h1>

				<nav class="frame__links">
					<a href="http://tympanus.net/Development/TextRepetitionEffect/">Previous demo</a>
					<a href="https://tympanus.net/codrops/?p=63293">Article</a>
					<a href="https://github.com/codrops/IntroTrailEffect">GitHub</a>
				</nav>
			</div>

			<h2 class="logo">
				<span class="logo__layer logo__layer--1" aria-hidden="true">ZD</span>
				<span class="logo__layer logo__layer--2" aria-hidden="true">ZD</span>
				<span class="logo__layer logo__layer--3">ZD</span>
			</h2>

			<button class="unbutton button-menu" aria-label="Open menu"></button>

			<span class="intro-progress">0%</span>

			<div class="intro-image" style="background-image:url(img/1.jpg);"></div>

			<div class="intro-content">
				<div class="intro-content__title intro-content__title--up">Zofia</div>
				<div class="intro-content__image">
					<!-- new place for intro-image -->
				</div>
				<div class="intro-content__title intro-content__title--down">Dab<em>ro</em>wski</div>
			</div>

			<button class="unbutton button-enter">
				<span>Enter</span>
			</button>

			<div class="content">
				<div class="content__title content__title--up"></div>
				<div class="content__title content__title--down"></div>
				<div class="content__about">
					<h4 class="content__about-title">About</h4>
					<div class="content__about-text">
						Some time ago a group of people were sitting in a restaurant, and one of them asked the others to say what they meant by Reality.
						There was much vague discussion, much talk of metaphysics and psychology, but one of those present, when asked his opinion, simply shrugged his shoulders and pointed at the saltshaker.
					</div>
				</div>
				<div class="content__image content__image--1">
					<div class="content__image-inner" style="background-image:url(img/2.jpg);"></div>
				</div>
				<div class="content__image content__image--2">
					<!-- final place for intro-image --> 
				</div>
				<div class="content__image content__image--3">
					<div class="content__image-inner" style="background-image:url(img/3.jpg);"></div>
				</div>
			</div>

		</main>
		<script src="https://tympanus.net/codrops/adpacks/cda_sponsor.js"></script>
		<script type="module" src="js/index.js"></script>
	</body>
</html>
함께 쓰는 파일 9개 보기
src/js/fakeProgress.js
파일 저장

import { gsap } from 'gsap';

/**
 * Class representing a fake progress loader
 */
export class FakeProgress {
	// DOM elements
	DOM = {
		// Main element
		el: null,
	};
	progressVal = {value: 0};

	/**
	 * Constructor.
	 * @param {Element} DOM_el
	 */
	constructor(DOM_el) {
		this.DOM.el = DOM_el;
	}
	/**
	 * Simulates a loading progress.
	 * @param {Function} onProgressComplete callback
	 * @return {GSAP Timeline}
	 */
	onComplete(onProgressComplete) {
		return gsap.timeline().to(this.progressVal, {
			duration: 1.5,
			ease: 'steps(14)',
			value: 100,
			onUpdate: () => this.DOM.el.innerHTML = Math.floor(this.progressVal.value) + '%',
			onComplete: onProgressComplete
		})
		// then hide it
		.to(this.DOM.el, {
			duration: 0.7,
			ease: 'power3.inOut',
			opacity: 0
		});
	}
}
src/js/gsapAnimation.js
파일 저장

export const animationDefaults = {
    duration: 1.4,
    ease: 'power4'
};
src/js/index.js
파일 저장

import { preloadImages } from './utils'
import { TrailImage, TrailText } from './trail';
import { FakeProgress } from './fakeProgress';
import { TextLinesReveal } from './textLinesReveal';
import { animationDefaults } from './gsapAnimation';
import { gsap } from 'gsap';
import { Flip } from 'gsap/Flip';
gsap.registerPlugin(Flip);

// trail elements (Image and the two intro title elements (up and down)
const trailImage = new TrailImage(document.querySelector('.intro-image'), {perspective: 1000, totalTrailElements: 8});
const trailTextTop = new TrailText(document.querySelector('.intro-content__title--up'), {perspective: 1000, totalTrailElements: 2});
const trailTextBottom = new TrailText(document.querySelector('.intro-content__title--down'), {totalTrailElements: 3});

// DOM elements
const frame = {
	menu: document.querySelector('.button-menu'),
	logo: document.querySelector('.logo'),
	progress: document.querySelector('.intro-progress')
};
const intro = {
	image: document.querySelector('.intro-content__image'),
	enterButton: document.querySelector('.button-enter'),
};
const content = {
	titleTop: document.querySelector('.content__title--up'),
	titleBottom: document.querySelector('.content__title--down'),
	about: document.querySelector('.content__about'),
	aboutText: document.querySelector('.content__about-text'),
	finalImagePlacement: document.querySelector('.content__image--2'),
	otherImages: document.querySelectorAll('.content__image--1 > .content__image-inner, .content__image--3 > .content__image-inner')
}

// the TextLinesReveal instance (animate each text line of the about text using the SplitText library)
const aboutLines = new TextLinesReveal(content.aboutText);

// state
let state = {
	isAnimating: false,
	iscontentOpen: false
};

// First step: fake progress and move the image to the center of the screen. Also animate the top/bottom texts in and show the enter button
const showIntro = () => {
	
	if ( state.isAnimating ) {
		return false;
	}
	state.isAnimating = true;

	gsap.timeline({
		defaults: animationDefaults,
		onComplete: () => {
			// Reset the trails structure on the texts and image
			trailTextTop.reset();
			trailTextBottom.reset();
			trailImage.reset();

			state.isAnimating = false;
		}
	})
	.addLabel('start', 0)
	.add(() => {
		// Let's use the gsap Flip plugin to animate the image into a new element (.intro-content__image)
		// Get state
		const state = Flip.getState(trailImage.DOM.trailElems);
		// Change place
		intro.image.appendChild(trailImage.DOM.el);
		// Flip
		Flip.from(state, {
			duration: animationDefaults.duration,
			ease: animationDefaults.ease,
			stagger: -0.03,
			scale: true
			//rotateY: 360,
		})
	}, 'start') 
	// Hide the intro title trail elements initially and show its parents which are hidden by default (CSS)
	.set([trailTextTop.DOM.trailElems, trailTextBottom.DOM.trailElems], {
		opacity: 0
	}, 'start')
	.set([trailTextTop.DOM.el, trailTextBottom.DOM.el], {
		opacity: 1
	}, 'start')
	// Now translate the title elements
	.to(trailTextTop.DOM.trailElems, {
		y: 0,
		startAt: {rotateY: 160, opacity: 0},
		rotateY: 0,
		opacity: 1,
		stagger: -0.1
	}, 'start')
	.to(trailTextBottom.DOM.trailElems, {
		y: 0,
		opacity: 1,
		stagger: -0.08,
	}, 'start')
	// And show the intro enter button
	.to(intro.enterButton, {
		startAt: {opacity: 0, scale: 0.8},
		opacity: 1,
		scale: 1
	}, 'start+=0.3')
	.add(() => {
		// Show the logo and menu button 
		frame.menu.classList.add('show');
		frame.logo.classList.add('show');
	}, 'start+=0.3');
	
};

// Second step: show the other images and scale down the texts
const showContent = () => {
	
	if ( state.isAnimating || state.iscontentOpen ) {
		return false;
	}
	state.isAnimating = true;
	state.iscontentOpen = true;

	gsap.timeline({
		defaults: animationDefaults,
		onComplete: () => {
			state.isAnimating = false;
		}
	})
	.addLabel('start', 0)
	.to(intro.enterButton, {
		duration: 0.6,
		opacity: 0, 
		scale: 0.8,
	}, 'start')
	.add(() => {

		const topTitleState = Flip.getState(trailTextTop.DOM.el);
		const bottomTitleState = Flip.getState(trailTextBottom.DOM.el);
		
		content.titleTop.appendChild(trailTextTop.DOM.el);
		content.titleBottom.appendChild(trailTextBottom.DOM.el);
		
		Flip.from(topTitleState, {
			duration: animationDefaults.duration,
			ease: animationDefaults.ease,
			scale: true
		});
		
		Flip.from(bottomTitleState, {
			duration: animationDefaults.duration,
			ease: animationDefaults.ease,
			scale: true
		});
		
		const imageState = Flip.getState(trailImage.DOM.el, {props: 'border-radius'});
		// Change place
		content.finalImagePlacement.appendChild(trailImage.DOM.el);
		gsap.set(trailImage.DOM.el, {opacity: 1});
		// Flip
		Flip.from(imageState, {
			duration: animationDefaults.duration,
			ease: animationDefaults.ease
		});
		
	}, 'start')
	
	// animate the other images in
	.to(content.otherImages, {
		startAt: {yPercent: 100},
		yPercent: 0,
		opacity: 1
	}, 'start+=0.1')
	// about section
	.to(content.about, {
		startAt: {yPercent: 10},
		yPercent: 0,
		opacity: 1
	}, 'start+=0.2')
	// about text lines
	.add( () => {
		aboutLines.in();
	}, 'start+=0.2')

};

// Enter button click event
intro.enterButton.addEventListener('click', showContent);

// Simulate the initial progress
const fakeProgress = new FakeProgress(frame.progress);
fakeProgress.onComplete(showIntro);

// Preload images
preloadImages('.intro-image').then( _ => document.body.classList.remove('loading'));



src/js/textLinesReveal.js
파일 저장

import SplitType from 'split-type';
import { animationDefaults } from './gsapAnimation';
import { wrapLines } from './utils';
import { gsap } from 'gsap';

/**
 * Class representing a text line element that reveals itself by animating its translateY value
 */
export class TextLinesReveal {
    // DOM elements
    DOM = {
        // main element (a text DOM element)
        el: null
    }
    // Split Type instance
    SplitTypeInstance;
    // Checks if the Split Type lines are visible or not
    isVisible;
    // Animation timelines
    inTimeline;
    outTimeline;

    /**
     * Constructor.
     * @param {Element} DOM_el - a text DOM element
     */
    constructor(DOM_el) {
        this.DOM = {
            el: DOM_el
        };

        this.SplitTypeInstance = new SplitType(this.DOM.el, { types: 'lines' });
        // Wrap the lines (div with class .oh)
        // The inner child will be the one animating the transform
        wrapLines(this.SplitTypeInstance.lines, 'div', 'oh');
        
        this.initEvents();
    }

    /**
     * Animates the lines in.
     * @return {GSAP Timeline} the animation timeline
     * @param {Boolean} animation - with or without animation.
     */
    in(animation = true) {
        // Lines are visible
        this.isVisible = true;

        gsap.killTweensOf(this.SplitTypeInstance.lines);
        this.inTimeline = gsap.timeline({defaults: animationDefaults})
        .addLabel('start', 0)
        .set(this.SplitTypeInstance.lines, {
            yPercent: 105
        }, 'start');
        
        if ( animation ) {
            this.inTimeline.to(this.SplitTypeInstance.lines, {
                yPercent: 0,
                stagger: 0.04
            }, 'start');
        }
        else {
            this.inTimeline.set(this.SplitTypeInstance.lines, {
                yPercent: 0
            }, 'start');
        }
        
        return this.inTimeline;
    }

    /**
     * Animates the lines out.
     * @param {Boolean} animation - with or without animation.
     * @return {GSAP Timeline} the animation timeline
     */
    out(animation = true) {
        // Lines are invisible
        this.isVisible = false;

        gsap.killTweensOf(this.SplitTypeInstance.lines);
        
        this.outTimeline = gsap.timeline({defaults: animationDefaults}).addLabel('start', 0);
        
        if ( animation ) {
            this.outTimeline.to(this.SplitTypeInstance.lines, {
                yPercent: -105,
                stagger: 0.04
            }, 'start');
        }
        else {
            this.outTimeline.set(this.SplitTypeInstance.lines, {
                yPercent: -105,
            }, 'start');
        }

        return this.outTimeline;
    }

    /**
     * Initializes some events.
     */
    initEvents() {
        // Re-initialize the Split Text on window resize.
        window.addEventListener('resize', () => {
            // Re-split text
            // https://github.com/lukePeavey/SplitType#instancesplitoptions-void
            this.SplitTypeInstance.split();

            // Need to wrap again the new lines elements (div with class .oh)
            wrapLines(this.SplitTypeInstance.lines, 'div', 'oh');
                
            // Hide the lines
            if ( !this.isVisible ) {
                gsap.set(this.SplitTypeInstance.lines, {yPercent: 105});
            }
        });
    }
}
src/js/trail.js
파일 저장

/**
 * Class representing a Trail element, 
 * an element that has [trailElems] children/clones (of type image or text) 
 * and that we can use to stagger it's translation so it looks like a trail or dragging effect 
 */
class Trail {
	// DOM elements
	DOM = {
		// Main element (.trail)
		el: null,
		// Trail child elements (.trail__img or .trail__text)
		trailElems: null,
	};
	// option defaults
	defaults = {
		// 3d
		perspective: false,
		// Total number of inner image elements
		totalTrailElements: 4,
	};

	/**
	 * Constructor.
	 * @param {Element} DOM_el - the .trail element
	 */
	constructor(DOM_el, options) {
		this.DOM.el = DOM_el;
		this.options = Object.assign(this.defaults, options);

		// 3d
		if ( this.options.perspective ) {
			this.DOM.el.style.perspective = `${this.options.perspective}px`
		}
	}
}

/**
 * Class representing an image trail element
 */
export class TrailImage extends Trail {
	// the image path
	bgImage;

	/**
	 * Constructor.
	 * @param {Element} DOM_el - the .trail element
	 */
	constructor(DOM_el, options) {
		super(DOM_el, options);
		// Get the main element's background image url 
		this.bgImage = /(?:\(['"]?)(.*?)(?:['"]?\))/.exec(this.DOM.el.style.backgroundImage)[1];
		// Create the HTML markup for the trail elements
		this.layout();
	}
	/**
	 * Creates the HTML markup for the trail elements
	 */
	layout() {
		// Remove the background image from the main element
		this.DOM.el.style.backgroundImage = 'none';

		let innerHTML = '';
		for (let i = 0; i <= this.options.totalTrailElements - 1; ++i) {
			const opacityVal = i === this.options.totalTrailElements - 1 ? 1 : 0.8;//1/this.options.totalTrailElements * i + 1/this.options.totalTrailElements
			innerHTML += `<img class="trail__img" src="${this.bgImage}" style="opacity: ${opacityVal}"/>`;
		}
		// Append to the main element
		this.DOM.el.innerHTML = innerHTML;

		// Get inner .trail__img elements
		this.DOM.trailElems = this.DOM.el.querySelectorAll('.trail__img');

		this.DOM.el.classList.add('trail');
	}
	reset() {
		this.DOM.el.classList.remove('trail');
		this.DOM.el.style.backgroundImage = `url(${this.bgImage})`;
		this.DOM.el.innerHTML = '';
		if ( this.options.perspective ) {
			this.DOM.el.style.perspective = 'none';
		}
	}
}

/**
 * Class representing a text trail element
 */
export class TrailText extends Trail {
	/**
	 * Constructor.
	 * @param {Element} DOM_el - the .trail element
	 */
	constructor(DOM_el, options) {
		super(DOM_el, options);
		// Create the HTML markup for the trail elements
		this.layout();
	}
	/**
	 * Creates the HTML markup for the trail elements
	 */
	layout() {
		// Get the main element's innerHTML
		this.content = this.DOM.el.innerHTML;

		let innerHTML = '';
		for (let i = 0; i <= this.options.totalTrailElements - 1; ++i) {
			const opacityVal = i === this.options.totalTrailElements - 1 ? 1 : 1/this.options.totalTrailElements * i + 1/this.options.totalTrailElements
			innerHTML += `<span class="trail__text" style="opacity: ${opacityVal}">${this.content}</span>`;
		}
		// Append to the main element
		this.DOM.el.innerHTML = innerHTML;

		// Get inner .trail__text elements
		this.DOM.trailElems = this.DOM.el.querySelectorAll('.trail__text');

		this.DOM.el.classList.add('trail');
	}
	reset() {
		this.DOM.el.classList.remove('trail');
		this.DOM.el.innerHTML = this.content;
		if ( this.options.perspective ) {
			this.DOM.el.style.perspective = 'none';
		}
	}
}
src/js/utils.js
파일 저장

const imagesLoaded = require('imagesloaded');

/**
 * Preload images
 * @param {String} selector - Selector/scope from where images need to be preloaded. Default is 'img'
 */
const preloadImages = (selector = 'img') => {
    return new Promise((resolve) => {
        imagesLoaded(document.querySelectorAll(selector), {background: true}, resolve);
    });
};

/**
 * Wraps the elements of an array.
 * @param {Array} arr - the array of elements to be wrapped
 * @param {String} wrapType - the type of the wrap element ('div', 'span' etc)
 * @param {String} wrapClass - the wrap class(es)
 */
const wrapLines = (arr, wrapType, wrapClass) => {
    arr.forEach(el => {
        const wrapEl = document.createElement(wrapType);
        wrapEl.classList = wrapClass;
        el.parentNode.appendChild(wrapEl);
        wrapEl.appendChild(el);
    });
}

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