GSAP 원본

Magnetic Button - overwrite modes

버튼 · MIT (public Pen panels); GSAP Standard No Charge License

버튼 더 보기
ORIGINAL PREVIEW
Magnetic Button - overwrite modes 정적 미리보기

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

큰 화면으로 보기 새 탭실행 HTML 저장

저장한 HTML에서는 갤러리의 재생 설정이 적용되지 않아요.

SOURCE FILES

원본 코드 읽기

6개 파일

수집한 원본 소스와 실행 안내를 함께 제공합니다. 실행 HTML에는 미리보기를 위한 실행 환경이 들어 있습니다.

vendor/gsap-previews/sources/gsap-68e98efad03d/index.html
파일 저장

<div class="header">
 <h1>Dynamic tweens <br/><code>overwrite: true</code> vs <code>"auto"</code></h1>
 <p></p>
</div>

<div class="demo-area">
 <div class="demo-col">
 <div class="demo-label"><b>magnetic only</b><br>no wiggle, overwrite: true</div>
 <div class="mag-zone" data-mode="true" data-wiggle="false">
 <button class="mag-btn summer" id="btnPlain">
 <div class="bg"></div>
 <span class="label">dynamic</span>
 </button>
 </div>
 <button class="code-peek" data-code="2">&lt;/&gt;</button>
 </div>
 <div class="demo-col">
 <div class="demo-label"><b>overwrite: false</b><br>tweens may conflict</div>
 <div class="mag-zone" data-mode="false" data-wiggle="false">
 <button class="mag-btn danger" id="btnFalse">
 <div class="bg"></div>
 <span class="label">false</span>
 </button>
 </div>
 <button class="code-peek" data-code="3">&lt;/&gt;</button>
 </div>
 <div class="demo-col">
 <div class="demo-label"><b>overwrite: true</b><br>kills ALL other tweens on target</div>
 <div class="mag-zone" data-mode="true" data-wiggle="true">
 <button class="mag-btn orange" id="btnTrue">
 <div class="bg"></div>
 <span class="label">true</span>
 </button>
 </div>
 <button class="code-peek" data-code="0">&lt;/&gt;</button>
 </div>
 <div class="demo-col">
 <div class="demo-label"><b>overwrite: "auto"</b><br>kills only conflicting props</div>
 <div class="mag-zone" data-mode="auto" data-wiggle="true">
 <button class="mag-btn macha" id="btnAuto">
 <div class="bg"></div>
 <span class="label">auto</span>
 </button>
 </div>
 <button class="code-peek" data-code="1">&lt;/&gt;</button>
 </div>
</div>

<div class="modal-overlay" id="modalOverlay">
 <div class="modal">
 <button class="modal-close" id="modalClose">×</button>
 <pre><code class="language-js" id="modalCode"></code></pre>
 </div>
</div>
<!-- <a target="_blank" href="https://gsap.com/resources/conflict/">learn more</a>
 -->
vendor/gsap-previews/sources/gsap-68e98efad03d/style.css
파일 저장


*,
*::before,
*::after {
 box-sizing: border-box;
 margin: 0;
 padding: 0;
}
:root {
 --green: #0ae448;
 --black: #0e100f;
 --white: #fffce1;
 --lt: #abff84;
 --grey: #191919;
 --s75: #bbbaa6;
 --s50: #7c7c6f;
 --s25: #42433d;
 --grad-macha: linear-gradient(114.41deg, #0ae448 20.74%, #abff84 65.5%);
 --grad-orange: linear-gradient(111.45deg, #ff8709 19.42%, #f7bdf8 73.08%);
}
body {
 font-family: Mori, sans-serif;
 background: var(--black);
 color: var(--s75);
 min-height: 100vh;
 display: flex;
 flex-direction: column;
 align-items: center;
 justify-content: center;
 gap: 40px;
 padding: 40px 16px;
}
.header {
 text-align: center;
 max-width: 520px;
}
.header h1 {
 color: var(--white);
 font-weight: 400;
 font-size: clamp(1.2rem, 3vw, 1.7rem);
}
.header p {
 color: var(--s50);
 margin-top: 5px;
 max-width: 48ch;
 margin-inline: auto;
}
code {
 font-family: Fraktion Mono, monospace;
 font-size: 0.78em;
 background: var(--grey);
 color: var(--white);
 padding: 2px 5px;
 border-radius: 4px;
}

.demo-area {
 display: flex;
 gap: 4rem;
 flex-wrap: wrap;
 justify-content: center;
 align-items: flex-start;
}
.demo-col {
 display: flex;
 flex-direction: column;
 align-items: center;
 gap: 8px;
 width: 40%;
 position: relative;
}
.demo-label {
 font-family: Fraktion Mono, monospace;
 font-size: 0.68rem;
 color: var(--s50);
 text-align: center;
}
.demo-label b {
 color: var(--white);
 font-weight: 400;
}

.code-peek {
 width: 24px;
 height: 24px;
 border-radius: 6px;
 border: 1px solid var(--s25);
 background: var(--grey);
 color: var(--s50);
 font-family: Fraktion Mono, monospace;
 font-size: 0.7rem;
 cursor: pointer;
 display: flex;
 align-items: center;
 justify-content: center;
 transition: all 0.15s;
 margin-top: 4px;
}
.code-peek:hover {
 border-color: var(--green);
 color: var(--green);
}

.modal-overlay {
 position: fixed;
 inset: 0;
 background: rgba(14, 16, 15, 0.8);
 z-index: 100;
 display: none;
 align-items: center;
 justify-content: center;
 padding: 16px;
}
.modal-overlay.open {
 display: flex;
}
.modal {
 background: var(--grey);
 border: 1px solid var(--s25);
 border-radius: 12px;
 padding: 20px;
 max-width: 800px;
 width: 100%;
 max-height: 80vh;
 overflow-y: auto;
 position: relative;
 display: flex;
 justify-content: center; 
}
.modal-close {
 position: absolute;
 top: 12px;
 right: 12px;
 width: 28px;
 height: 28px;
 border-radius: 6px;
 background: transparent;
 color: var(--s50);
 cursor: pointer;
 font-family: Fraktion Mono, monospace;
 font-size: 1.2rem;
 display: flex;
 align-items: center;
 justify-content: flex-start;
 border: none;
}
.modal-close:hover {
 border-color: var(--green);
 color: var(--green);
}
.modal pre {
 margin: 0;
}

.modal code[class*="language-"] {
 font-size: 0.7rem;
 line-height: 1;
}

code[class*="language-"], pre[class*="language-"] {
 max-width: none;
}

.mag-zone {
 width: 200px;
 height: 200px;
 display: flex;
 align-items: center;
 justify-content: center;
 border-radius: 50%;
 border: 1px dashed var(--s25);
 position: relative;
 cursor: pointer;
}
.mag-btn {
 position: relative;
 display: flex;
 align-items: center;
 justify-content: center;
 padding: 16px 32px;
 border-radius: 99px;
 border: none;
 cursor: pointer;
 font-family: Mori, sans-serif;
 font-weight: 600;
 font-size: 0.85rem;
 color: var(--black);
 overflow: hidden;
 will-change: transform;
}
.mag-btn .bg {
 position: absolute;
 inset: 0;
 border-radius: 99px;
 z-index: 0;
}
.mag-btn .label {
 position: relative;
 z-index: 1;
 pointer-events: none;
}
.mag-btn.macha .bg {
 background: var(--grad-macha);
}
.mag-btn.orange .bg {
 background: var(--grad-orange);
}
.mag-btn.summer .bg {
 background: var(--gradient-summer-fair);
}
.mag-btn.danger .bg {
 background: var(--gradient-lipstick);
}



.code-box {
 width: 100%;
 max-width: 520px;
 background: var(--grey);
 border: 1px solid var(--s25);
 border-radius: 8px;
 padding: 12px 16px;
 overflow-x: auto;
}
.code-box pre {
 margin: 0;
}
.code-box code {
 font-size: 0.8rem;
 white-space: pre;
 background: none;
 padding: 0;
 border-radius: 0;
}

.details {
 width: 100%;
 max-width: 520px;
}
.details p {
 font-family: Fraktion Mono, monospace;
 font-size: 0.62rem;
 color: var(--s50);
 line-height: 1.4;
 margin-top: 4px;
}
함께 쓰는 파일 4개 보기
vendor/gsap-previews/sources/gsap-68e98efad03d/script.js
파일 저장


gsap.registerPlugin(CustomEase, CustomWiggle);
 
/* ── code modal ── */
var modalSnippets = [
 // 0 — overwrite: true + wiggle
 '// wiggle loop\ngsap.to(btn, {\n rotation: 12,\n duration: 1.5,\n repeat: -1,\n ease: "wiggle({wiggles:8, type:easeOut})"\n});\n\n// magnetic pull — overwrite: true kills the wiggle!\nzone.addEventListener("mousemove", (e) => {\n const rect = zone.getBoundingClientRect();\n const x = gsap.utils.mapRange(rect.left, rect.right,-rect.width / 2, rect.width / 2, e.clientX);\n const y = gsap.utils.mapRange(rect.top, rect.bottom, -rect.height / 2, rect.height / 2, e.clientY);\n\n gsap.to(btn, {\n x: x * strength,\n y: y * strength,\n duration: 0.4,\n ease: "power2.out",\n overwrite: true\n });\n});\n\nzone.addEventListener("mouseleave", () => {\n gsap.to(btn, { x: 0, y: 0,\n duration: 0.7,\n ease: "elastic.out(1, 0.4)",\n overwrite: true\n });\n});',
 
 // 1 — overwrite: "auto" + wiggle
 '// wiggle loop\ngsap.to(btn, {\n rotation: 12,\n duration: 1.5,\n repeat: -1,\n ease: "wiggle({wiggles:8, type:easeOut})"\n});\n\n// magnetic pull — overwrite: "auto" keeps the wiggle!\nzone.addEventListener("mousemove", (e) => {\n const rect = zone.getBoundingClientRect();\n const x = gsap.utils.mapRange(rect.left, rect.right,-rect.width / 2, rect.width / 2, e.clientX);\n const y = gsap.utils.mapRange(rect.top, rect.bottom, -rect.height / 2, rect.height / 2, e.clientY);\n\n gsap.to(btn, {\n x: x * strength,\n y: y * strength,\n duration: 0.4,\n ease: "power2.out",\n overwrite: "auto"\n });\n});\n\nzone.addEventListener("mouseleave", () => {\n gsap.to(btn, { x: 0, y: 0,\n duration: 0.7,\n ease: "elastic.out(1, 0.4)",\n overwrite: "auto"\n });\n // wiggle is still running\n});',
 
 // 2 — no wiggle, overwrite: true
 '// no wiggle — simply overwriting x and y. \nzone.addEventListener("mousemove", (e) => {\n const rect = zone.getBoundingClientRect();\n const x = gsap.utils.mapRange(rect.left, rect.right,-rect.width / 2, rect.width / 2, e.clientX);\n const y = gsap.utils.mapRange(rect.top, rect.bottom,-rect.height / 2, rect.height / 2, e.clientY);\n\n gsap.to(btn, {\n x: x * strength,\n y: y * strength,\n duration: 0.4,\n ease: "power2.out",\n overwrite: true\n });\n});\n\nzone.addEventListener("mouseleave", () => {\n gsap.to(btn, { \n x: 0, \n y: 0,\n duration: 0.7,\n ease: "elastic.out(1, 0.4)",\n overwrite: true\n });\n});',
 
 // 3 — overwrite: false (long move, snappy leave)
 '// magnetic pull — LONG duration on mousemove\nzone.addEventListener("mousemove", (e) => {\n const rect = zone.getBoundingClientRect();\n const x = gsap.utils.mapRange(rect.left, rect.right,-rect.width / 2, rect.width / 2, e.clientX);\n const y = gsap.utils.mapRange(rect.top, rect.bottom, -rect.height / 2, rect.height / 2, e.clientY);\n\n gsap.to(btn, {\n x: x * strength,\n y: y * strength,\n duration: 1.5, // slow follow\n ease: "power2.out",\n overwrite: false // default — won\'t kill anything\n });\n});\n\n// SHORT snappy mouseleave — finishes fast,\n// but the old long mousemove tween is still going\n// and reclaims x/y → visible snap-back!\nzone.addEventListener("mouseleave", () => {\n gsap.to(btn, { x: 0, y: 0,\n duration: 0.15,\n ease: "power2.out",\n overwrite: false\n });\n});'
];
 
var overlay = document.getElementById("modalOverlay");
var modalCode = document.getElementById("modalCode");
 
document.querySelectorAll(".code-peek").forEach(function(btn) {
 btn.addEventListener("click", function(e) {
 e.stopPropagation();
 var idx = parseInt(btn.getAttribute("data-code"));
 modalCode.textContent = modalSnippets[idx];
 if (window.Prism) Prism.highlightElement(modalCode);
 overlay.classList.add("open");
 });
});
 
document.getElementById("modalClose").addEventListener("click", function() {
 overlay.classList.remove("open");
});
 
overlay.addEventListener("click", function(e) {
 if (e.target === overlay) overlay.classList.remove("open");
});
 
/* ── magnetic buttons ── */
var zones = document.querySelectorAll(".mag-zone");
var strength = 0.4;
var labelStrength = 0.24;
 
zones.forEach(function(zone) {
 var btn = zone.querySelector(".mag-btn");
 var label = btn.querySelector(".label");
 var mode = zone.getAttribute("data-mode");
 var overwrite = mode === "true" ? true : mode === "false" ? false : "auto";
 var isFalse = mode === "false";
 var hasWiggle = zone.getAttribute("data-wiggle") === "true";
 
 // attention-seeking wiggle (if enabled)
 if (hasWiggle) {
 gsap.to(btn, {
 rotation: 12,
 duration: 1.5,
 repeat: -1,
 ease: "wiggle({wiggles:8,type:easeOut})"
 });
 }
 
 zone.addEventListener("mousemove", function(e) {
 var rect = zone.getBoundingClientRect();
 var mapX = gsap.utils.mapRange(rect.left, rect.right, -rect.width / 2, rect.width / 2, e.clientX);
 var mapY = gsap.utils.mapRange(rect.top, rect.bottom, -rect.height / 2, rect.height / 2, e.clientY);
 
 gsap.to(btn, {
 x: mapX * strength,
 y: mapY * strength,
 duration: isFalse ? 1.5 : 0.4,
 ease: "power2.out",
 overwrite: overwrite
 });
 
 gsap.to(label, {
 x: mapX * labelStrength,
 y: mapY * labelStrength,
 duration: isFalse ? 1.5 : 0.4,
 ease: "power2.out",
 overwrite: true
 });
 });
 
 zone.addEventListener("mouseleave", function() {
 gsap.to(btn, {
 x: 0, y: 0,
 duration: isFalse ? 0.5 : 0.7,
 ease: isFalse ? "power2.out" : "elastic.out(1,0.4)",
 overwrite: overwrite
 });
 
 gsap.to(label, {
 x: 0, y: 0,
 duration: isFalse ? 0.5 : 0.7,
 ease: isFalse ? "power2.out" : "elastic.out(1,0.4)",
 overwrite: true
 });
 });
});
vendor/gsap-previews/sources/gsap-68e98efad03d/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);--color-ui-gradient-background:linear-gradient(135deg,#fbadce,#897dff);--color-text-gradient:linear-gradient(135deg,#fbadce,#897dff);--gradient-summer-fair:linear-gradient(135deg,#ffd28c,#fbadce);--gradient-lipstick:linear-gradient(135deg,#fbadce,#fc7f8e);--gradient-macha:linear-gradient(135deg,#b5f4da,#75d8ed);--color-grey:#898e9f;--color-grey-dark:#414859;--color-scroll-pink-lt:#fbadce;--color-text-purple:#b5a1ff;--surface50:#898e9f;--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-68e98efad03d/adapters/script.js실행 안내·자료
파일 저장

window.__STYLEGALLERY_ASSETS__={};
gsap.registerPlugin(CustomEase, CustomWiggle);
var modalSnippets = [
  // 0 — overwrite: true + wiggle
  '// wiggle loop\ngsap.to(btn, {\n rotation: 12,\n duration: 1.5,\n repeat: -1,\n ease: "wiggle({wiggles:8, type:easeOut})"\n});\n\n// magnetic pull — overwrite: true kills the wiggle!\nzone.addEventListener("mousemove", (e) => {\n const rect = zone.getBoundingClientRect();\n const x = gsap.utils.mapRange(rect.left, rect.right,-rect.width / 2, rect.width / 2, e.clientX);\n const y = gsap.utils.mapRange(rect.top, rect.bottom, -rect.height / 2, rect.height / 2, e.clientY);\n\n gsap.to(btn, {\n x: x * strength,\n y: y * strength,\n duration: 0.4,\n ease: "power2.out",\n overwrite: true\n });\n});\n\nzone.addEventListener("mouseleave", () => {\n gsap.to(btn, { x: 0, y: 0,\n duration: 0.7,\n ease: "elastic.out(1, 0.4)",\n overwrite: true\n });\n});',
  // 1 — overwrite: "auto" + wiggle
  '// wiggle loop\ngsap.to(btn, {\n rotation: 12,\n duration: 1.5,\n repeat: -1,\n ease: "wiggle({wiggles:8, type:easeOut})"\n});\n\n// magnetic pull — overwrite: "auto" keeps the wiggle!\nzone.addEventListener("mousemove", (e) => {\n const rect = zone.getBoundingClientRect();\n const x = gsap.utils.mapRange(rect.left, rect.right,-rect.width / 2, rect.width / 2, e.clientX);\n const y = gsap.utils.mapRange(rect.top, rect.bottom, -rect.height / 2, rect.height / 2, e.clientY);\n\n gsap.to(btn, {\n x: x * strength,\n y: y * strength,\n duration: 0.4,\n ease: "power2.out",\n overwrite: "auto"\n });\n});\n\nzone.addEventListener("mouseleave", () => {\n gsap.to(btn, { x: 0, y: 0,\n duration: 0.7,\n ease: "elastic.out(1, 0.4)",\n overwrite: "auto"\n });\n // wiggle is still running\n});',
  // 2 — no wiggle, overwrite: true
  '// no wiggle — simply overwriting x and y. \nzone.addEventListener("mousemove", (e) => {\n const rect = zone.getBoundingClientRect();\n const x = gsap.utils.mapRange(rect.left, rect.right,-rect.width / 2, rect.width / 2, e.clientX);\n const y = gsap.utils.mapRange(rect.top, rect.bottom,-rect.height / 2, rect.height / 2, e.clientY);\n\n gsap.to(btn, {\n x: x * strength,\n y: y * strength,\n duration: 0.4,\n ease: "power2.out",\n overwrite: true\n });\n});\n\nzone.addEventListener("mouseleave", () => {\n gsap.to(btn, { \n x: 0, \n y: 0,\n duration: 0.7,\n ease: "elastic.out(1, 0.4)",\n overwrite: true\n });\n});',
  // 3 — overwrite: false (long move, snappy leave)
  `// magnetic pull — LONG duration on mousemove
zone.addEventListener("mousemove", (e) => {
 const rect = zone.getBoundingClientRect();
 const x = gsap.utils.mapRange(rect.left, rect.right,-rect.width / 2, rect.width / 2, e.clientX);
 const y = gsap.utils.mapRange(rect.top, rect.bottom, -rect.height / 2, rect.height / 2, e.clientY);

 gsap.to(btn, {
 x: x * strength,
 y: y * strength,
 duration: 1.5, // slow follow
 ease: "power2.out",
 overwrite: false // default — won't kill anything
 });
});

// SHORT snappy mouseleave — finishes fast,
// but the old long mousemove tween is still going
// and reclaims x/y → visible snap-back!
zone.addEventListener("mouseleave", () => {
 gsap.to(btn, { x: 0, y: 0,
 duration: 0.15,
 ease: "power2.out",
 overwrite: false
 });
});`
];
var overlay = document.getElementById("modalOverlay");
var modalCode = document.getElementById("modalCode");
document.querySelectorAll(".code-peek").forEach(function(btn) {
  btn.addEventListener("click", function(e) {
    e.stopPropagation();
    var idx = parseInt(btn.getAttribute("data-code"));
    modalCode.textContent = modalSnippets[idx];
    if (window.Prism) Prism.highlightElement(modalCode);
    overlay.classList.add("open");
  });
});
document.getElementById("modalClose").addEventListener("click", function() {
  overlay.classList.remove("open");
});
overlay.addEventListener("click", function(e) {
  if (e.target === overlay) overlay.classList.remove("open");
});
var zones = document.querySelectorAll(".mag-zone");
var strength = 0.4;
var labelStrength = 0.24;
zones.forEach(function(zone) {
  var btn = zone.querySelector(".mag-btn");
  var label = btn.querySelector(".label");
  var mode = zone.getAttribute("data-mode");
  var overwrite = mode === "true" ? true : mode === "false" ? false : "auto";
  var isFalse = mode === "false";
  var hasWiggle = zone.getAttribute("data-wiggle") === "true";
  if (hasWiggle) {
    gsap.to(btn, {
      rotation: 12,
      duration: 1.5,
      repeat: -1,
      ease: "wiggle({wiggles:8,type:easeOut})"
    });
  }
  zone.addEventListener("mousemove", function(e) {
    var rect = zone.getBoundingClientRect();
    var mapX = gsap.utils.mapRange(rect.left, rect.right, -rect.width / 2, rect.width / 2, e.clientX);
    var mapY = gsap.utils.mapRange(rect.top, rect.bottom, -rect.height / 2, rect.height / 2, e.clientY);
    gsap.to(btn, {
      x: mapX * strength,
      y: mapY * strength,
      duration: isFalse ? 1.5 : 0.4,
      ease: "power2.out",
      overwrite
    });
    gsap.to(label, {
      x: mapX * labelStrength,
      y: mapY * labelStrength,
      duration: isFalse ? 1.5 : 0.4,
      ease: "power2.out",
      overwrite: true
    });
  });
  zone.addEventListener("mouseleave", function() {
    gsap.to(btn, {
      x: 0,
      y: 0,
      duration: isFalse ? 0.5 : 0.7,
      ease: isFalse ? "power2.out" : "elastic.out(1,0.4)",
      overwrite
    });
    gsap.to(label, {
      x: 0,
      y: 0,
      duration: isFalse ? 0.5 : 0.7,
      ease: isFalse ? "power2.out" : "elastic.out(1,0.4)",
      overwrite: true
    });
  });
});
LICENSE실행 안내·자료
파일 저장

<!--

Copyright (c) 2026 - GreenSock - https://codepen.io/GreenSock/pen/azmKBBJ

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.