GSAP 원본
MacOS Dock Effect
탐색 · MIT (public Pen panels); GSAP Standard No Charge License
갤러리 안에서는 화면을 벗어나거나 움직임을 멈추면 예제도 닫힙니다. 다시 재생할 때는 처음부터 시작해요.
저장한 HTML에서는 갤러리의 재생 설정이 적용되지 않아요.
SOURCE FILES
원본 코드 읽기
수집한 원본 소스와 실행 안내를 함께 제공합니다. 실행 HTML에는 미리보기를 위한 실행 환경이 들어 있습니다.
vendor/gsap-previews/sources/gsap-ed59448cf1f3/index.html
<!-- forked from the amazing Blake bowen for posterity 💚 -->
<!-- https://codepen.io/osublake/pen/GYzqjL -->
<div class="wrapper">
<ul class="toolbar">
<li class="toolbarItem">
<a class="toolbarLink" href="#!">
<img class="toolbarImg" src="https://assets.codepen.io/16327/2D-star.png" alt="">
</a>
</li>
<li class="toolbarItem">
<a class="toolbarLink" href="#!">
<img class="toolbarImg" src="https://assets.codepen.io/16327/2D-wobble.png" alt="">
</a>
</li>
<li class="toolbarItem">
<a class="toolbarLink" href="#!">
<img class="toolbarImg" src="https://assets.codepen.io/16327/2D-windmill.png" alt="">
</a>
</li>
<li class="toolbarItem">
<a class="toolbarLink" href="#!">
<img class="toolbarImg" src="https://assets.codepen.io/16327/2D-sparkle.png" alt="">
</a>
</li>
<li class="toolbarItem">
<a class="toolbarLink" href="#!">
<img class="toolbarImg" src="https://assets.codepen.io/16327/2D-lightning.png" alt="">
</a>
</li>
<li class="toolbarItem">
<a class="toolbarLink" href="#!">
<img class="toolbarImg" src="https://assets.codepen.io/16327/2D-flower.png" alt="">
</a>
</li>
<li class="toolbarItem">
<a class="toolbarLink" href="#!">
<img class="toolbarImg" src="https://assets.codepen.io/16327/2D-diamond.png" alt="">
</a>
</li>
<li class="toolbarItem">
<a class="toolbarLink" href="#!">
<img class="toolbarImg" src="https://assets.codepen.io/16327/2D-keyframe.png" alt="">
</a>
</li>
<li class="toolbarItem">
<a class="toolbarLink" href="#!">
<img class="toolbarImg" src="https://assets.codepen.io/16327/3D-combo.png" alt="">
</a>
</li>
<li class="toolbarItem">
<a class="toolbarLink" href="#!">
<img class="toolbarImg" src="https://assets.codepen.io/16327/2D-label.png" alt="">
</a>
</li>
<li class="toolbarItem">
<a class="toolbarLink" href="#!">
<img class="toolbarImg" src="https://assets.codepen.io/16327/3D-cone.png" alt="">
</a>
</li>
<li class="toolbarItem">
<a class="toolbarLink" href="#!">
<img class="toolbarImg" src="https://assets.codepen.io/16327/3D-hoop.png" alt="">
</a>
</li>
</ul>
</div>vendor/gsap-previews/sources/gsap-ed59448cf1f3/style.css
body {
width: 100%;
margin: 0;
}
.wrapper {
position: fixed;
bottom: 0;
left: 50%;
transform: translate(-50%);
display: flex;
justify-content: center;
}
.toolbar {
display: inline-flex;
justify-content: center;
align-items: flex-end;
height: 40px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
margin: 0;
padding: 10px;
background-color: rgba(55, 66, 77, 0.25);
list-style: none;
}
.toolbarItem {
width: 40px;
height: 40px;
margin: 0 4px;
}
.toolbarLink {
display: block;
height: 100%;
}
.toolbarImg {
display: block;
width: 100%;
height: 100%;
object-fit: contain;
border-radius: 50%;
}
함께 쓰는 파일 4개 보기
vendor/gsap-previews/sources/gsap-ed59448cf1f3/script.js
console.clear();
let icons = document.querySelectorAll(".toolbarItem");
let dock = document.querySelector(".toolbar");
let firstIcon = icons[0];
let min = 48; // 40 + margin
let max = 120;
let bound = min * Math.PI;
gsap.set(icons, {
transformOrigin: "50% 120%",
height: 40
});
gsap.set(dock, {
position: "relative",
height: 60
});
dock.addEventListener("mousemove", (event) => {
let offset = dock.getBoundingClientRect().left + firstIcon.offsetLeft;
updateIcons(event.clientX - offset);
});
dock.addEventListener("mouseleave", (event) => {
gsap.to(icons, {
duration: 0.3,
scale: 1,
x: 0
});
});
function updateIcons(pointer) {
for (let i = 0; i < icons.length; i++) {
let icon = icons[i];
let distance = (i * min + min / 2) - pointer;
let x = 0;
let scale = 1;
if (-bound < distance && distance < bound) {
let rad = distance / min * 0.5;
scale = 1 + (max / min - 1) * Math.cos(rad);
x = 2 * (max - min) * Math.sin(rad);
} else {
x = (-bound < distance ? 2 : -2) * (max - min);
}
gsap.to(icon, {
duration: 0.3,
x: x,
scale: scale
});
}
}vendor/gsap-previews/sources/gsap-ed59448cf1f3/adapters/host.css실행 안내·자료
/* StyleGallery host styles: independent replacement for unavailable shared Pen CSS. */
:root{--color-just-black:#111522;--color-surface-white:#f7f3ec;--color-surface75:#cfccc6;--color-surface50:#898e9f;--color-surface25:#414859;--color-shockingly-green:#95efd2;--color-lt-green:#b5f4da;--color-pink:#fbadce;--color-purple:#897dff;--color-lilac:#b5a1ff;--color-orangey:#ffd28c;--color-blue:#75d8ed;--color-ui-gradient:linear-gradient(135deg,#fbadce,#897dff);--light:#f7f3ec;--dark:#111522;--mid:#898e9f}
*{box-sizing:border-box}body{background:#111522;color:#f7f3ec;font-family:system-ui,sans-serif;margin:0;min-height:100vh;width:100%}button,input{font:inherit}button,.button{background:#111522;border:1px solid #898e9f;border-radius:.55rem;color:#f7f3ec;cursor:pointer;padding:.65rem 1rem}button:focus-visible,a:focus-visible,input:focus-visible{outline:3px solid #95efd2;outline-offset:4px}h1,h2,h3,h4{line-height:1.15}h4{font-weight:500}code{font-family:ui-monospace,monospace}.heading-l{font-size:clamp(2rem,6vw,5rem)}.heading-text{font-size:clamp(1.5rem,4vw,3rem)}.box{background:#95efd2;border-radius:14px;height:clamp(38px,12vw,80px);width:clamp(38px,12vw,80px)}.green{background:#95efd2}.purple{background:#897dff}.orange{background:#ffd28c}.gradient-pink{background:linear-gradient(140deg,#fbadce,#fc7f8e)}.gradient-purple{background:linear-gradient(140deg,#b5a1ff,#537ff7)}.center{align-items:center;display:flex;justify-content:center}.text-center{text-align:center}.panel{min-height:100vh;width:100%}.flair:not(img){background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNDgiIGhlaWdodD0iMjQ4IiB2aWV3Qm94PSIwIDAgMjQ4IDI0OCI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJnIiB4Mj0iMSIgeTI9IjEiPjxzdG9wIHN0b3AtY29sb3I9IiNiNWExZmYiLz48c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiM3NWQ4ZWQiLz48L2xpbmVhckdyYWRpZW50PjwvZGVmcz48ZyBmaWxsPSJ1cmwoI2cpIj48cGF0aCBkPSJNODcgMjBoNzR2NjdoNjd2NzRoLTY3djY3SDg3di02N0gyMFY4N2g2N1oiLz48L2c+PC9zdmc+");background-position:center;background-repeat:no-repeat;background-size:contain;height:80px;width:80px}.flair--3:not(img){background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNDgiIGhlaWdodD0iMjQ4IiB2aWV3Qm94PSIwIDAgMjQ4IDI0OCI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJnIiB4Mj0iMSIgeTI9IjEiPjxzdG9wIHN0b3AtY29sb3I9IiM5NWVmZDIiLz48c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiM1MzdmZjciLz48L2xpbmVhckdyYWRpZW50PjwvZGVmcz48ZyBmaWxsPSJ1cmwoI2cpIj48Y2lyY2xlIGN4PSIxMjQiIGN5PSIxMjQiIHI9Ijg4IiBmaWxsPSJub25lIiBzdHJva2U9InVybCgjZykiIHN0cm9rZS13aWR0aD0iNDgiLz48Y2lyY2xlIGN4PSIxODMiIGN5PSI2MCIgcj0iMjMiIGZpbGw9IiNmNmYzZWIiLz48L2c+PC9zdmc+")}.braces{font-size:1rem}img{max-width:100%}
/* External font programs are omitted; preserve readable fallback typography. */
body,button,input,h1,h2,h3,h4,p,span,div{font-family:inherit}body{font-family:system-ui,sans-serif}code,pre{font-family:ui-monospace,monospace}
vendor/gsap-previews/sources/gsap-ed59448cf1f3/adapters/script.js실행 안내·자료
window.__STYLEGALLERY_ASSETS__={};
console.clear();
let icons = document.querySelectorAll(".toolbarItem");
let dock = document.querySelector(".toolbar");
let firstIcon = icons[0];
let min = 48;
let max = 120;
let bound = min * Math.PI;
gsap.set(icons, {
transformOrigin: "50% 120%",
height: 40
});
gsap.set(dock, {
position: "relative",
height: 60
});
dock.addEventListener("mousemove", (event) => {
let offset = dock.getBoundingClientRect().left + firstIcon.offsetLeft;
updateIcons(event.clientX - offset);
});
dock.addEventListener("mouseleave", (event) => {
gsap.to(icons, {
duration: 0.3,
scale: 1,
x: 0
});
});
function updateIcons(pointer) {
for (let i = 0; i < icons.length; i++) {
let icon = icons[i];
let distance = i * min + min / 2 - pointer;
let x = 0;
let scale = 1;
if (-bound < distance && distance < bound) {
let rad = distance / min * 0.5;
scale = 1 + (max / min - 1) * Math.cos(rad);
x = 2 * (max - min) * Math.sin(rad);
} else {
x = (-bound < distance ? 2 : -2) * (max - min);
}
gsap.to(icon, {
duration: 0.3,
x,
scale
});
}
}
LICENSE실행 안내·자료
<!--
Copyright (c) 2025 - GreenSock - https://codepen.io/GreenSock/pen/PwNeKZy
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.
-->
GSAP 3.15.0
Copyright 2026, GreenSock. All rights reserved.
Subject to the Standard No Charge License: https://gsap.com/standard-license.
The full notice in each original GSAP library file is preserved.
StyleGallery host adapter and replacement SVG subjects: locally authored.
BEHIND THE EXAMPLE
이 장면을 만드는 원리
거리 함수와 고정된 아이콘 간격
기하 측정 기준과 실제 레이아웃 입력을 일치시켜야 합니다.
- 이 예제에서는
- 도크 왼쪽 위치와 첫 아이콘 offsetLeft를 기준으로 포인터 좌표를 계산합니다. 각 아이콘의 고정 간격 min=48과 코사인·사인 함수로 scale과 x를 구합니다. 열두 아이콘이 좁은 화면을 넘을 수 있으며, CSS로 간격만 바꾸면 이 계산의 48과 어긋납니다.
