Codrops 원본

Tooltip to Gallery Transition

카드 · MIT

카드 더 보기
ORIGINAL PREVIEW
Tooltip to Gallery Transition 정적 미리보기

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

큰 화면으로 보기 새 탭

SOURCE FILES

원본 코드 읽기

9개 파일

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

src/css/base.css
파일 저장

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

:root {
	font-size: 16px;
	--color-text: #322b43;
	--color-bg: hsl(180deg 49% 92%);
	--color-link: #322b43;
	--color-link-hover: #322b43;
	--frame-font-size: 0.85rem;
	--padding-frame: 1rem;
	--color-line: #8a88bf;
	--side-space: 0;
	--gap: 1rem;
	--size-text: 1rem;
	--size-meta: 0.85rem;
	--margin-text: 5vw;
	--color-selected: rgba(114,121,239,0.7);
}

html {
	background: var(--color-bg);
	height: 100%;
}

body {
	margin: 0;
	color: var(--color-text);
	background-color: var(--color-bg);
	height: 100%;
	font-family: sans-serif;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	background: radial-gradient(at 40% 40%, #74519c, #0000), radial-gradient(at 60% 60%, #a4c5ec, #0000);
    background-blend-mode: lighten;
    overflow: hidden;
}

/* 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: #9da2d0;
}

.js .loading::after {
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	margin: auto;
	border-radius: 50%;
	box-sizing: border-box;
	width: 8rem;
	height: 8rem;
	border: 3px solid hsla(0, 0%, 100%, 0.5);
	border-top-color: hsla(0, 0%, 100%, 0.8);
	animation: loaderAnim 0.7s linear infinite forwards;

}

@keyframes loaderAnim {
	to {
		transform: rotate(1turn);
	}
}

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

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

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

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

.unbutton:focus {
	outline: none;
}

main {
	display: grid;
	align-items: center;
	height: 100vh;
	position: relative;
}

.frame {
	color: var(--color-title);
	padding: var(--padding-frame);
	text-transform: uppercase;
	height: auto;
    font-size: var(--frame-font-size);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
}

.frame a:not(.frame__title-back),
.hover-line {
	white-space: nowrap;
	overflow: hidden;
	position: relative;
	align-self: start;
}

.frame a:not(.frame__title-back)::before, 
.hover-line::before {
	content: '';
	height: 1px;
	width: 100%;
	background: currentColor;
	position: absolute;
	top: 90%;
	transition: transform 1s cubic-bezier(0.84, 0, 0.16, 1);
	transform-origin: 0% 50%;
}

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

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

.frame__title-main {
	font-size: var(--frame-font-size);
	margin: 0;
	font-weight: 400;
}

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

.frame__title-back span {
	display: none;
}

.frame__title-back svg {
	fill: currentColor;
}

.frame__prev {
	grid-area: prev;
	margin: 0.5rem 0;
	display: inline-block;
}

.content {
	display: grid;
	width: 100%;
	grid-template-rows: auto 50px 1fr;
	grid-template-columns: 1fr;
	grid-template-areas: 'title' 'tooltip' 'text';
	padding: var(--padding-frame);
	font-size: var(--size-text);
	line-height: 1.45;
	grid-gap: var(--gap);
	position: relative;
}

.content__title-wrap {
	grid-area: title;
}

.content__pretitle {
	font-size: var(--size-meta);
	display: grid;
	grid-template-columns: 100%;
	grid-template-rows: 100%;
	justify-items: start;
}

.meta,
.back {
	position: relative;
	grid-area: 1 / 1 / -1 / -1;
}

.back {
	pointer-events: none;
}

.back .oh__inner {
	transform: translateY(100%);
}

.content--open .back {
	pointer-events: auto;
}

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

.content__title {
	font-family: campaign-serif, sans-serif;
	font-weight: normal;
	font-size: clamp(2rem,10vw,4rem);
	margin: 0 0 0.5rem 0;
	line-height: 1;
}

.content__text,
.gallery {
	grid-area: text;
}

.content__text {
	margin-right: var(--margin-text);
	transition: opacity 0.5s;
	will-change: opacity;
}

.content--open .content__text {
	opacity: 0;
	pointer-events: none;
}

.content__text p {
	margin: 0;
}

.gallery {
	position: relative;
	display: grid;
	pointer-events: none;
}

.content--open .gallery {
	pointer-events: auto;
}

.gallery__title {
	position: absolute;
	top: 100%;
	font-size: var(--size-meta);
}

.gallery__title .oh__inner {
	transform: translateY(100%);
}

.gallery--fullscreen {
	position: fixed;
	width: 100vw;
	height: 100vh;
	top: 0;
	left: 0;
}

.tooltip {
	grid-area: tooltip;
	pointer-events: none;
	font-size: 0.85rem;
	opacity: 0;
	display: flex;
	gap: 1rem;
}

.tooltip__text {
	margin: 0;
}

.tooltip__img-wrap {
	display: grid;
}

.tooltip__img {
	grid-area: 1 / 1 / -1 / -1;
	width: 50px;
	height: 50px;
	opacity: 0;
	will-change: transform;
}

.gallery .tooltip__img {
	aspect-ratio: auto;
	width: 100%;
	height: 100%;
	cursor: zoom-in;
}

.gallery--fullscreen .tooltip__img {
	cursor: zoom-out;
}

.tooltip__img--current {
	opacity: 1;
}

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

.tooltip strong {
	display: block;
	margin-top: 1rem;
}

.line {
	background: var(--color-line);
	position: fixed;
	will-change: transform;
	pointer-events: none;
}

.line--v {
	height: 100%;
	width: 1px;
	top: 0;
}

.line--h {
	width: 100%;
	height: 1px;
	left: 0;
}

.nav {
	grid-area: tooltip;
	display: grid;
	grid-auto-columns: 1fr;
	grid-auto-flow: column;
	grid-gap: 1rem;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.5s;
}

.content--open .nav {
	opacity: 1;
	pointer-events: auto;
}

.nav__img {
	max-width: 160px;
	cursor: not-allowed;
	will-change: transform;
}

.nav__img--selected {
	border: 2px solid var(--color-selected);
}

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

.nav--fullscreen {
	position: fixed;
	bottom: 6vh;
	left: 10%;
	width: 80%;
	height: 70px;
	grid-auto-columns: 1fr;
	grid-auto-flow: column;
	justify-content: center;
}

@media screen and (min-width: 53em) {
	:root {
		--padding-frame: 1.5rem;
		--gap: 2rem;
		--size-text: 1.45rem;
	}
	.frame {
		position: fixed;
		margin: 0;
		display: grid;
		grid-template-columns: 1fr 1fr 1fr;
		grid-template-rows: auto auto;
		align-content: space-between;
		height: 100vh;
		grid-template-areas: 'title ... sponsor' 'prev ... ...';
		grid-gap: 2rem;
		justify-content: start;
    	justify-items: start;
	}
	.frame__prev {
		margin: 0;
	}
	.content {
		grid-template-rows: auto 1fr;
		grid-template-columns: var(--side-space) 1fr 215px var(--side-space);
		grid-template-areas: '... title ... ...' '... text tooltip ...';
	}
	.content::before,
	.content::after {
		opacity: 0.3;
		position: absolute;
		pointer-events: none;
		bottom: calc(100% + 1rem);
		left: calc(var(--gap) + var(--padding-frame));
		right: calc(215px + var(--gap) + var(--padding-frame) + var(--margin-text));
		content: "This is claimed to help in the acceptance of robots in certain replicative behaviors which are usually performed by people. Such robots attempt to replicate walking, lifting, speech, cognition, or any other human activity. Many of today's robots are inspired by nature, contributing to the field of bio-inspired robotics";
		transition: transform 0.5s, opacity 0.5s;
	}

	.content::after {
		top: calc(100% + 1rem);
		bottom: auto;
		content: "The concept of creating robots that can operate autonomously dates back to classical times, but research into the functionality and potential uses of robots did not grow substantially until the 20th century. ";
	}

	.content--open::before {
		opacity: 0;
		transform: translateY(-1rem);
	}

	.content--open::after {
		opacity: 0;
		transform: translateY(1rem);
	}
	.nav {
		grid-auto-rows: 1fr;
		grid-auto-flow: row;
	}
	.content--open .nav.nav--fullscreen {
		grid-auto-rows: 1fr;
		grid-auto-flow: column;
	}
	.tooltip {
		flex-direction: column;
	}
	.tooltip__img {
		width: 100%;
		aspect-ratio: 1.75;
		height: auto;
	}
}


@media screen and (min-width: 70em) {
	:root {
		--side-space: 15vw;
	}
	.frame {
		grid-template-columns: var(--side-space) 1fr 215px var(--side-space);
		grid-template-areas: 'title ... sponsor sponsor' 'prev ... ... ...';
	}
	.content::before,
	.content::after {
		left: calc(var(--side-space) + var(--gap) + var(--padding-frame));
		right: calc(215px + var(--side-space) + var(--gap) + var(--padding-frame) + var(--margin-text));
	}
}
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>Sidebar Tooltip Transitions | Codrops</title>
		<meta name="description" content="A concept for a tooltip page transitions to a gallery and fullscreen image." />
		<meta name="keywords" content="gsap, flip, animation, page transition, image, tooltip, sidebar" />
		<meta name="author" content="Codrops" />
		<link rel="shortcut icon" href="favicon.ico">
		<link rel="stylesheet" href="https://use.typekit.net/wnx0vhl.css">
		<link rel="stylesheet" type="text/css" href="css/base.css" />
		<script>document.documentElement.className="js";var supportsCssVars=function(){var e,t=document.createElement("style");return t.innerHTML="root: { --tmp-var: bold; }",document.head.appendChild(t),e=!!(window.CSS&&window.CSS.supports&&window.CSS.supports("font-weight","var(--tmp-var)")),t.parentNode.removeChild(t),e};supportsCssVars()||alert("Please view this demo in a modern browser that supports CSS Variables.");</script>
		<script src="//tympanus.net/codrops/adpacks/analytics.js"></script>
	</head>
	<body class="loading">
		<main>
			<div class="frame">
				<div class="frame__title"> 
					<h1 class="frame__title-main">Tooltip Transition</h1> 
					<a aria-label="Back to the article" class="frame__title-back" href="https://tympanus.net/codrops/?p=66204"> 
						<span class="oh__inner">Back to the article</span> 
						<svg width="18px" height="18px" viewBox="0 0 24 24"><path vector-effect="non-scaling-stroke" d="M18.25 15.5a.75.75 0 00.75-.75v-9a.75.75 0 00-.75-.75h-9a.75.75 0 000 1.5h7.19L6.22 16.72a.75.75 0 101.06 1.06L17.5 7.56v7.19c0 .414.336.75.75.75z"></path>
						</svg>
					</a>
				</div>
				<a class="frame__prev" href="https://tympanus.net/Tutorials/PencilLines/">Previous demo</a>
			</div>
			<div class="content">
				<div class="content__title-wrap">
					<div class="content__pretitle">
						<button class="back unbutton oh"><span class="oh__inner">&#9664; Back</span></button>
						<span class="meta oh"><span class="oh__inner">23XA B320</span></span>
					</div>
					<h2 class="content__title">Robotics</h2>
				</div>
				<div class="content__text">
					<p>Robotics develops machines that can substitute for humans and replicate human actions. Robots can be used in many <strong><a class="hover-line" data-tooltip>situations</a></strong> for many purposes, but today many are used in dangerous environments (including inspection of radioactive materials, bomb detection and deactivation), manufacturing processes, or where humans cannot survive (e.g. in space, underwater, in high heat, and clean up and containment of hazardous materials and radiation). Certain robots require user input to operate while other robots function autonomously.</p>
				</div>
				<div class="gallery">
					<!--div class="tooltip__img tooltip__img--current"><div class="tooltip__img-inner" style="background-image:url(img/1.webp)"></div></div-->
					<h3 class="gallery__title oh"><span class="oh__inner">Transistor Equation</span></h3>
				</div>
				<div class="nav">
					<div class="nav__img"><div class="nav__img-inner" style="background-image:url(img/1.webp)"></div></div>
					<div class="nav__img"><div class="nav__img-inner" style="background-image:url(img/2.webp)"></div></div>
					<div class="nav__img"><div class="nav__img-inner" style="background-image:url(img/3.webp)"></div></div>
					<div class="nav__img"><div class="nav__img-inner" style="background-image:url(img/4.webp)"></div></div>
					<div class="nav__img"><div class="nav__img-inner" style="background-image:url(img/5.webp)"></div></div>
					<div class="nav__img"><div class="nav__img-inner" style="background-image:url(img/6.webp)"></div></div>
				</div>
				<aside class="tooltip">
					<div class="tooltip__img-wrap">
						<div class="tooltip__img"><div class="tooltip__img-inner" style="background-image:url(img/1.webp)"></div></div>
						<div class="tooltip__img"><div class="tooltip__img-inner" style="background-image:url(img/2.webp)"></div></div>
						<div class="tooltip__img"><div class="tooltip__img-inner" style="background-image:url(img/3.webp)"></div></div>
						<div class="tooltip__img"><div class="tooltip__img-inner" style="background-image:url(img/4.webp)"></div></div>
						<div class="tooltip__img"><div class="tooltip__img-inner" style="background-image:url(img/5.webp)"></div></div>
						<div class="tooltip__img"><div class="tooltip__img-inner" style="background-image:url(img/6.webp)"></div></div>
					</div>
					<p class="tooltip__text">The set of things that are happening and the conditions that exist at a particular time and place.<strong>Click for more</strong></p>
				</aside>
			</div>

			<div class="line line--h" style="top: -1px;"></div>
			<div class="line line--h" style="top: 100vh;"></div>

			<div class="line line--v" style="left: -1px;"></div>
			<div class="line line--v" style="left: 100vw;"></div>
		</main>
		<script src="https://tympanus.net/codrops/adpacks/cda_sponsor.js"></script>
		<script type="module" src="js/index.js"></script>
	</body>
</html>
함께 쓰는 파일 7개 보기
src/js/index.js
파일 저장

import { preloadImages } from './utils';
import { Tooltip } from './tooltip';
import { LinesController } from './linesController';
import { gsap } from 'gsap';
import { Flip } from 'gsap/Flip';
gsap.registerPlugin(Flip);

// .content element
const content = document.querySelector('.content');

// link that when hovered triggers the effect
const link = document.querySelector('a[data-tooltip]');

// object representing the images slideshow that animates on hover.
const tooltip = new Tooltip(document.querySelector('aside.tooltip'));

// 4 lines that move around
const lineController = new LinesController([...document.querySelectorAll('.line')]);

// .gallery element
const gallery = document.querySelector('.gallery');

// gallery title inner text element: .gallery__title > .oh__inner
const galleryTitle = document.querySelector('.gallery__title > .oh__inner');

// .content__pretitle text elements:
// back control to main page and title
const pretitle = {
    back: document.querySelector('.content__pretitle > .back > .oh__inner'),
    title: document.querySelector('.content__pretitle > .oh:not(.back) > .oh__inner')
};

// .nav and .nav__img elements
const nav = document.querySelector('.nav');
const navImages = [...nav.querySelectorAll('.nav__img')];

// gsap timelines
let entertl, leavetl, clicktl, zoomintl, zoomouttl, backtl;

// true after clicking the link and showing the gallery
let isGalleryOpen = false;

// true after zooming/clicking the gallery image 
let isFullscreen = false;

// window size
let winsize = { width: window.innerWidth, height: window.innerHeight };

let isAnimating = false;

// zoom in / zoom out
const toggleZoom = _ => isFullscreen ? zoomOut() : zoomIn();

const zoomIn = () => {
    
    if ( isAnimating ) return;
    isAnimating = true;

    const flipstateNav = Flip.getState(navImages, {simple: true});
    const flipstateGallery = Flip.getState(tooltip.DOM.images[tooltip.current], {simple: true});
    
    // add fullscreen classes to both the gallery and nav elements
    gallery.classList.add('gallery--fullscreen');
    nav.classList.add('nav--fullscreen');

    // lines final positions
    const imageRect = tooltip.DOM.images[tooltip.current].getBoundingClientRect();
    const linePos = {
        // first and second horizontal lines y translations
        horizontal: [imageRect.top, -winsize.height + (imageRect.top + tooltip.DOM.images[tooltip.current].offsetHeight)],
        // first and second vertical lines x translations
        vertical: [imageRect.left, -winsize.width + (imageRect.left + tooltip.DOM.images[tooltip.current].offsetWidth)]
    };

    zoomintl = gsap.timeline({
        defaults: {
            duration: 0.7,
            ease: 'power4'
        },
        onStart: () => isFullscreen = true,
        onComplete: () => isAnimating = false
    })
    .addLabel('start', 0)
    .add(() => {
        const flipOpts = {
            duration: zoomintl.vars.defaults.duration,
            ease: zoomintl.vars.defaults.ease,
            scale: true
        };
        Flip.from(flipstateNav, flipOpts)
        Flip.from(flipstateGallery, flipOpts);
    }, 'start')
    .to(lineController.DOM.linesHorizontal[0], {
        y: linePos.horizontal[0],
        opacity: 1
    }, 'start')
    .to(lineController.DOM.linesHorizontal[1], {
        y: linePos.horizontal[1],
        opacity: 1
    }, 'start')
    .to(lineController.DOM.linesVertical[0], {
        x: linePos.vertical[0],
        opacity: 1
    }, 'start')
    .to(lineController.DOM.linesVertical[1], {
        x: linePos.vertical[1],
        opacity: 1
    }, 'start');

};

const zoomOut = () => {

    if ( isAnimating ) return;
    isAnimating = true;

    const flipstateNav = Flip.getState(navImages, {simple: true});
    const flipstateGallery = Flip.getState(tooltip.DOM.images[tooltip.current], {simple: true});
    
    gallery.classList.remove('gallery--fullscreen');
    nav.classList.remove('nav--fullscreen');
    
    // lines final positions
    const galleryRect = gallery.getBoundingClientRect();
    const linePos = {
        // first and second horizontal lines y translations
        horizontal: [galleryRect.top, -winsize.height + (galleryRect.top + gallery.offsetHeight)],
        // first and second vertical lines x translations
        vertical: [galleryRect.left, -winsize.width + (galleryRect.left + gallery.offsetWidth)]
    };
    
    zoomouttl = gsap.timeline({
        defaults: {
            duration: 0.7,
            ease: 'power4'
        },
        onStart: () => isFullscreen = false,
        onComplete: () => isAnimating = false
    })
    .addLabel('start', 0)
    .add(() => {
        const flipOpts = {
            duration: zoomouttl.vars.defaults.duration,
            ease: zoomouttl.vars.defaults.ease,
            scale: true
        };
        Flip.from(flipstateNav, flipOpts);
        Flip.from(flipstateGallery, flipOpts);
    }, 'start')
    .to(lineController.DOM.linesHorizontal[0], {
        y: linePos.horizontal[0],
        opacity: 1
    }, 'start')
    .to(lineController.DOM.linesHorizontal[1], {
        y: linePos.horizontal[1],
        opacity: 1
    }, 'start')
    .to(lineController.DOM.linesVertical[0], {
        x: linePos.vertical[0],
        opacity: 1
    }, 'start')
    .to(lineController.DOM.linesVertical[1], {
        x: linePos.vertical[1],
        opacity: 1
    }, 'start');

};

// hover effect (show auto slideshow)
link.addEventListener('mouseenter', () => {

    // disable the mouse hover events after clicking on the link
    if ( isGalleryOpen ) return;

    // kill the mouseleave event timeline if active
    if ( leavetl ) {
        leavetl.kill();
    }

    // line final positions
    const linePos = {
        // first and second horizontal lines y translations
        horizontal: [tooltip.rect.top, -winsize.height + (tooltip.rect.top + tooltip.DOM.images[tooltip.current].offsetHeight)],
        // first and second vertical lines x translations
        vertical: [tooltip.rect.left, -winsize.width + (tooltip.rect.left + tooltip.DOM.images[tooltip.current].offsetWidth)]
    };

    entertl = gsap.timeline({
        defaults: {
            duration: 1,
            ease: 'power4.inOut'
        }
    })
    .addLabel('start', 0)
    .to(lineController.DOM.linesHorizontal[0], {
        startAt: {
            y: linePos.horizontal[0]-100, 
            opacity: 0
        },
        y: linePos.horizontal[0],
        opacity: 1
    }, 'start')
    .to(lineController.DOM.linesHorizontal[1], {
        startAt: {
            y: linePos.horizontal[1]+100, 
            opacity: 0
        },
        y: linePos.horizontal[1],
        opacity: 1
    }, 'start')
    .to(lineController.DOM.linesVertical[0], {
        startAt: {
            x: linePos.vertical[0]-100,
            opacity: 0
        },
        x: linePos.vertical[0],
        opacity: 1
    }, 'start')
    .to(lineController.DOM.linesVertical[1], {
        startAt: {
            x:linePos.vertical[1]+100, 
            opacity: 0
        },
        x: linePos.vertical[1],
        opacity: 1
    }, 'start')
    .to(tooltip.DOM.el, {
        opacity: 1
    }, 'start+=0.2')
    .add(() => {
        tooltip.startSlideshow();
    }, 'start+=0.7')

});

link.addEventListener('mouseleave', () => {
    
    // disable the mouse hover events after clicking on the link
    if ( isGalleryOpen ) return;

    // kill the mouseenter event timeline if active
    if ( entertl ) {
        entertl.kill();
    }

    leavetl = gsap.timeline({
        defaults: {
            duration: 1,
            ease: 'power4.inOut'
        },
        onStart: () => tooltip.stopSlideshow(),
        onComplete: () => tooltip.reset(),
    })
    .addLabel('start', 0)
    .to(tooltip.DOM.el, {
        duration: 0.6,
        opacity: 0
    }, 'start')
    .to(lineController.DOM.lines, {
        x: 0,
        y: 0,
        opacity: 0
    }, 'start');

});

// click effect (show gallery)
link.addEventListener('click', () => {
    
    if ( isAnimating ) return;
    isAnimating = true;

    isGalleryOpen = true;

    if ( entertl ) {
        entertl.kill();
    }
    if ( leavetl ) {
        leavetl.kill();
    }

    tooltip.stopSlideshow();

    // line final positions
    const galleryRect = gallery.getBoundingClientRect();
    const linePos = {
        // first and second horizontal lines y translations
        horizontal: [galleryRect.top, -winsize.height + (galleryRect.top + gallery.offsetHeight)],
        // first and second vertical lines x translations
        vertical: [galleryRect.left, -winsize.width + (galleryRect.left + gallery.offsetWidth)]
    };

    clicktl = gsap.timeline({
        onStart: () => {
            content.classList.add('content--open');

            // hide all navImages initially so we can animate them in later
            gsap.set(navImages, {opacity: 0});

            // set nav current
            const navCurrent = navImages.find(img => img.classList.contains('nav__img--selected'));
            if ( navCurrent ) {
                navCurrent.classList.remove('nav__img--selected');
            }
            navImages[tooltip.current].classList.add('nav__img--selected');
        },
        onComplete: () => isAnimating = false,
        defaults: {
            duration: 0.7,
            ease: 'power4'
        }
    })
    .addLabel('start', 0)
    .to(lineController.DOM.linesHorizontal[0], {
        y: linePos.horizontal[0],
        opacity: 1
    }, 'start')
    .to(lineController.DOM.linesHorizontal[1], {
        y: linePos.horizontal[1],
        opacity: 1
    }, 'start')
    .to(lineController.DOM.linesVertical[0], {
        x: linePos.vertical[0],
        opacity: 1
    }, 'start')
    .to(lineController.DOM.linesVertical[1], {
        x: linePos.vertical[1],
        opacity: 1
    }, 'start')
    .add(() => {
        const flipstate = Flip.getState(tooltip.DOM.images[tooltip.current], {simple: true});
        
        gallery.prepend(tooltip.DOM.images[tooltip.current]);
        
        const flipOpts = {
            duration: clicktl.vars.defaults.duration,
            ease: clicktl.vars.defaults.ease,
            scale: true
        };
        Flip.from(flipstate, flipOpts);

        // zoom in/out when clicking on the current tooltip image
        tooltip.DOM.images[tooltip.current].addEventListener('click', toggleZoom);
    }, 'start')
    .to(tooltip.DOM.el, {
        duration: 0.4,
        opacity: 0
    }, 'start')
    .to(navImages, {
        startAt: {xPercent: 50},
        opacity: 1,
        xPercent: 0,
        stagger: 0.06
    }, 'start')
    .to(galleryTitle, {
        y: 0
    }, 'start')
    .to(pretitle.back, {
        y: 0
    }, 'start')
    .to(pretitle.title, {
        y: '-100%'
    }, 'start');

});

// back to main page
pretitle.back.addEventListener('click', () => {

    if ( isAnimating ) return;
    isAnimating = true;

    // remove the click event (zoom in/out) for the current tooltip image
    tooltip.DOM.images[tooltip.current].removeEventListener('click', toggleZoom);

    isGalleryOpen = false;

    const linePos = {
        // first and second horizontal lines y translations
        horizontal: [winsize.height, -winsize.height],
        // first and second vertical lines x translations
        vertical: [winsize.width, -winsize.width]
    };

    backtl = gsap.timeline({
        onComplete: () => {
            isAnimating = false;
        },
        defaults: {
            duration: 1,
            ease: 'power4.inOut'
        }
    })
    .addLabel('start', 0)
    .to(navImages, {
        duration: 0.5,
        opacity: 0,
        xPercent: 150,
        onComplete: () => content.classList.remove('content--open')
    }, 'start+=0.15')
    .to(pretitle.back, {
        y: '100%'
    }, 'start')
    .to(pretitle.title, {
        y: 0
    }, 'start')
    .to(galleryTitle, {
        y: '100%'
    }, 'start')
    .to(lineController.DOM.linesHorizontal[0], {
        y: linePos.horizontal[0]
    }, 'start')
    .to(lineController.DOM.linesHorizontal[1], {
        y: linePos.horizontal[1]
    }, 'start')
    .to(lineController.DOM.linesVertical[0], {
        x: linePos.vertical[0]
    }, 'start')
    .to(lineController.DOM.linesVertical[1], {
        x: linePos.vertical[1]
    }, 'start')
    .to(tooltip.DOM.images[tooltip.current], {
        duration: 0.85,
        //ease: 'expo',
        scale: 0,
        opacity: 0,
        onComplete: () => {
            tooltip.DOM.wrap.prepend(tooltip.DOM.images[tooltip.current]);
            gsap.set(tooltip.DOM.images[tooltip.current], {scale: 1, opacity: 1});
        }
    }, 'start');
    
});

// resize event
window.addEventListener('resize', () => {

    // update winsize
    winsize = { width: window.innerWidth, height: window.innerHeight };

    if ( !isGalleryOpen || isFullscreen ) return;

    // line final positions
    const galleryRect = gallery.getBoundingClientRect();
    const linePos = {
        // first and second horizontal lines y translations
        horizontal: [galleryRect.top, -winsize.height + (galleryRect.top + gallery.offsetHeight)],
        // first and second vertical lines x translations
        vertical: [galleryRect.left, -winsize.width + (galleryRect.left + gallery.offsetWidth)]
    };

    gsap.set(lineController.DOM.linesHorizontal[0], { y: linePos.horizontal[0] });
    gsap.set(lineController.DOM.linesHorizontal[1], { y: linePos.horizontal[1] });
    gsap.set(lineController.DOM.linesVertical[0], { x: linePos.vertical[0] });
    gsap.set(lineController.DOM.linesVertical[1], { x: linePos.vertical[1] });

});

// Preload images
preloadImages('.tooltip__img-inner, nav__img-inner').then(() => document.body.classList.remove('loading'));
src/js/linesController.js
파일 저장

/**
 * Class representing the 4 lines that move along with the images
 */
 export class LinesController {
	// DOM elements
	DOM = {
		// all the 4 lines (.line)
		lines: null,
	};
	
	/**
	 * Constructor.
	 * @param {Element} DOM_elems - main element (.line)
	 */
	constructor(DOM_elems) {
		this.DOM.lines = DOM_elems;
        this.DOM.linesVertical = this.DOM.lines.filter(line => line.classList.contains('line--v'));
        this.DOM.linesHorizontal = this.DOM.lines.filter(line => line.classList.contains('line--h'));
	}
}
src/js/tooltip.js
파일 저장

import { gsap } from 'gsap';

/**
 * Class representing the tooltip / slideshow
 */
 export class Tooltip {
	// DOM elements
	DOM = {
		// the main element (.tooltip)
		el: null,
        // .tooltip__img-wrap
        wrap: null,
        // tooltip images (.tooltip__img)
        images: null,
        // tooltiop text (.tooltip__text)
        text: null,
	};
    // current tooltip image
    current = 0;
    // total images
    imagesTotal = -1;
    // interval of time between each image display (slideshow)
    slideshowInterval = 0.4
	
	/**
	 * Constructor.
	 * @param {Element} DOM_el - main element (.tooltip)
	 */
	constructor(DOM_el) {
		this.DOM.el = DOM_el;
        this.DOM.wrap = this.DOM.el.querySelector('.tooltip__img-wrap');
        this.DOM.images = [...this.DOM.el.querySelectorAll('.tooltip__img')];
        this.imagesTotal = this.DOM.images.length;
        this.DOM.text = this.DOM.el.querySelector('.tooltip__text');

        // set current class for the first image
        this.DOM.images[this.current].classList.add('tooltip__img--current');

        this.calcRect(); 
        window.addEventListener('resize', () => this.calcRect());
	}
    /**
     * Get positions
     */
    calcRect() {
        this.rect = this.DOM.el.getBoundingClientRect();
    }
    /**
     * Starts the auto slideshow
     */
    startSlideshow() {
        this.showNextImage();
    }
    /**
     * change current image
     */
    showNextImage() {
        this.slideshow = gsap.delayedCall(this.slideshowInterval, () => {
            // update current
            this.DOM.images[this.current].classList.remove('tooltip__img--current');
            this.current = this.current < this.imagesTotal-1 ? ++this.current : 0;
            this.DOM.images[this.current].classList.add('tooltip__img--current');

            this.showNextImage();
        });
    }
    /**
     * Stops the auto slideshow
     */
    stopSlideshow() {
        if ( this.slideshow ) {
            this.slideshow.kill();
        }
    }
    /**
     * resets and update current to the original value 
     */
    reset() {
        // update current
        this.DOM.images[this.current].classList.remove('tooltip__img--current');
        this.current = 0;
        this.DOM.images[this.current].classList.add('tooltip__img--current');
    }
}
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.