GSAP 사례 연구
FLIP gallery modal
카드 · MIT (local companion); GSAP Standard No Charge License (runtime)
갤러리 안에서는 화면을 벗어나거나 움직임을 멈추면 예제도 닫힙니다. 다시 재생할 때는 처음부터 시작해요.
저장한 HTML에서는 갤러리의 재생 설정이 적용되지 않아요.
SOURCE FILES
독립 예제 코드 읽기
사례의 구도나 문서의 원리를 바탕으로 새로 만든 예제입니다. 아래 코드를 복사해 직접 응용할 수 있습니다. 실행 HTML에는 미리보기를 위한 실행 환경이 들어 있습니다.
vendor/gsap-previews/sources/gsap-160507325ef2/study-brief.json실행 안내·자료
{
"id": "gsap-160507325ef2",
"sourceId": "gsap",
"title": "FLIP gallery modal",
"sourceUrl": "https://demos.gsap.com/demo/flip-gallery-modal",
"demoUrl": "https://codepen.io/GreenSock/pen/XWOeLEb",
"sourceStatus": "unresolved",
"sourceReason": "Public page unavailable through web browsing",
"sourceRevision": null,
"sourceLicense": null,
"originalDemoAcquired": false,
"disposition": "ready_for_independent_study",
"evidenceBasis": "exact_same_original_pen_as_catalog_row_with_explicit_api_link",
"studyId": "gsap-988440b33c85",
"sharedStudyCanonicalId": "gsap-988440b33c85",
"label": "Independently authored documentation study; original Pen unavailable",
"catalogEvidence": {
"localPath": "artifacts/full-import/gsap/remaining-docs/catalog-evidence.json",
"sha256": "4f2a4f9aa64456b85b905b562b60d7733629b41026787b3057cba29e8b10de69",
"bytes": 30117,
"recordId": "gsap-160507325ef2"
},
"sourceInputs": [
{
"kind": "authored-study-specification",
"localPath": "artifacts/full-import/gsap/remaining-docs/study-specs.json",
"sha256": "cbb89331eda8783b5cf2f173b326b9195eeabfb223374fb60019161d9f46d4a6",
"bytes": 52279,
"recordId": "gsap-160507325ef2"
},
{
"kind": "official-catalog-metadata",
"localPath": "artifacts/full-import/gsap/remaining-docs/catalog-evidence.json",
"sha256": "4f2a4f9aa64456b85b905b562b60d7733629b41026787b3057cba29e8b10de69",
"bytes": 30117,
"recordId": "gsap-160507325ef2"
},
{
"kind": "official-documentation-evidence",
"localPath": "artifacts/full-import/gsap/remaining-docs/official-documentation-evidence.json",
"sha256": "bfa25f561e61c597569cf1bc0b3538e6dce4b9985a932775ceab41e665ca24a2",
"bytes": 11430,
"recordIds": [
"flip-state",
"flip"
]
},
{
"kind": "original-library-source",
"localPath": "artifacts/full-import/gsap/library/src/Flip.js",
"sha256": "02d87b469498badf49957f4e8ad0d1b5eb9689742cb4bdb06e2c7dc53554d918",
"gitBlob": "7e7a3d988fde077ed173e01a54e6c74ed8e38156",
"revision": "13e2b790546426a1a2e0e9b409f3f8dc6d6611f2",
"sourcePath": "src/Flip.js",
"ranges": [
{
"id": "flip-state-from",
"startLine": 952,
"endLine": 966,
"rangeSha256": "47528e5c46b86a139a4deccf9b1df4698fe2e47b206c94536bc8099f68a5aa5e"
}
]
}
],
"studiedPrinciple": "Share the independently authored capture-change-animate gallery study with Simple Grid FLIP Modal. Both original catalog rows point to XWOeLEb; this is an exact URL alias, not a title-based guess.",
"namedApis": [
{
"name": "Flip.getState(tile), Flip.from(state)",
"purpose": "Use the same API study as the canonical gsap-988440b33c85 brief.",
"libraryEvidence": [
"flip-state-from"
],
"documentationEvidence": [
"flip-state",
"flip"
]
}
],
"implementationBrief": {
"scene": "Use the canonical gsap-988440b33c85 authored gallery-to-dialog scene and preserve this second original ID as an alias.",
"controls": [
{
"label": "Open tile",
"type": "button",
"action": "Follow the canonical modal opening contract."
},
{
"label": "Close",
"type": "button",
"action": "Follow the canonical capture-before-restore contract and return focus."
},
{
"label": "Static view",
"type": "toggle",
"action": "Use the canonical nonanimated dialog path."
}
],
"mechanismSteps": [
"Read the complete canonical record gsap-988440b33c85 before implementation.",
"Verify both catalog evidence records have demoUrl https://codepen.io/GreenSock/pen/XWOeLEb.",
"Implement or reuse the one canonical independent study, map both original IDs to it, and label both as independent documentation studies.",
"Do not claim that the two original titles represent two independently observed animations."
]
},
"authoredDefaults": {
"inheritFromStudyId": "gsap-988440b33c85",
"independentCodeCopiesRequired": false
},
"verificationRequired": [
"Both original IDs resolve to the same runnable study without one disappearing from the catalog.",
"The canonical modal behavioral checks pass for this alias route too.",
"The alias retains its original title/source URL and declares that its implementation is a shared independent study."
],
"unsupportedClaims": [
"Original composition, assets, timing, breakpoint behavior, and live interaction are not observable in captured frames. This brief does not establish visual fidelity or recover original code.",
"This row has no body or API links itself. Its API association comes from the exact same original Pen on gsap-988440b33c85, which explicitly links Flip.getState.",
"Distinct original visuals or behavior between the two catalog routes have not been observed."
],
"dependencies": {
"package": "gsap",
"version": "3.15.0",
"revision": "13e2b790546426a1a2e0e9b409f3f8dc6d6611f2",
"repository": "https://github.com/greensock/GSAP",
"plugins": [
"Flip"
],
"registration": "gsap.registerPlugin(Flip) after loading core and those plugin scripts",
"runtimeCandidates": [
{
"path": "dist/gsap.js",
"localPath": "artifacts/full-import/gsap/library/dist/gsap.js",
"gitBlob": "ec5ffee3f099bc454f2f1c79cee6a55ba97e7400",
"sha256": "01effe0e121c22ba0f885a3f091f3dc6d1f0d445c4fba37dcb298e314eca5cfb",
"bytes": 179557
},
{
"path": "dist/Flip.js",
"localPath": "artifacts/full-import/gsap/library/dist/Flip.js",
"gitBlob": "6a3aa6c954b0020706dcd9764e88e9ef739bd2c7",
"sha256": "3c732c2ab4b5bcaf1b9835b1722376019b743f7641280acc342040623b248d75",
"bytes": 54494
}
],
"license": {
"name": "GSAP Standard 'No Charge' License (custom, not MIT)",
"localPath": "artifacts/full-import/gsap/licenses/gsap-standard-license.html",
"sha256": "bf8536e67b77db780f7db0c14a645f184f554bb19e938d1e52d58986e2f10528",
"bytes": 6988,
"url": "https://gsap.com/community/standard-license/"
},
"originalDependencyVersionKnown": false
},
"runtimeVerified": false,
"implementationWritten": false
}
vendor/gsap-previews/sources/gsap-160507325ef2/source-inputs.json실행 안내·자료
[
{
"kind": "authored-study-specification",
"localPath": "artifacts/full-import/gsap/remaining-docs/study-specs.json",
"sha256": "cbb89331eda8783b5cf2f173b326b9195eeabfb223374fb60019161d9f46d4a6",
"bytes": 52279,
"recordId": "gsap-160507325ef2"
},
{
"kind": "official-catalog-metadata",
"localPath": "artifacts/full-import/gsap/remaining-docs/catalog-evidence.json",
"sha256": "4f2a4f9aa64456b85b905b562b60d7733629b41026787b3057cba29e8b10de69",
"bytes": 30117,
"recordId": "gsap-160507325ef2"
},
{
"kind": "official-documentation-evidence",
"localPath": "artifacts/full-import/gsap/remaining-docs/official-documentation-evidence.json",
"sha256": "bfa25f561e61c597569cf1bc0b3538e6dce4b9985a932775ceab41e665ca24a2",
"bytes": 11430,
"recordIds": [
"flip-state",
"flip"
]
},
{
"kind": "original-library-source",
"localPath": "artifacts/full-import/gsap/library/src/Flip.js",
"sha256": "02d87b469498badf49957f4e8ad0d1b5eb9689742cb4bdb06e2c7dc53554d918",
"gitBlob": "7e7a3d988fde077ed173e01a54e6c74ed8e38156",
"revision": "13e2b790546426a1a2e0e9b409f3f8dc6d6611f2",
"sourcePath": "src/Flip.js",
"ranges": [
{
"id": "flip-state-from",
"startLine": 952,
"endLine": 966,
"rangeSha256": "47528e5c46b86a139a4deccf9b1df4698fe2e47b206c94536bc8099f68a5aa5e"
}
]
}
]
함께 쓰는 파일 4개 보기
vendor/gsap-previews/sources/gsap-160507325ef2/index.html실행 안내·자료
<main class="study"><p class="study-label">공식 API 기반 · 독립 예제</p><header><h2>같은 도형의 자리 바꾸기</h2><p>선택한 도형 하나를 대화상자로 옮깁니다. 원래 자리에는 같은 크기의 빈칸을 남깁니다.</p></header><div class="stage gallery-stage"><div class="tile-grid"><button class="gallery-opener" type="button" aria-label="Mint 카드 열기"><span class="gallery-visual" style="--tile:#95efd2"><svg viewBox="0 0 120 120" aria-hidden="true"><path d="m60 7 15 31 34 5-25 24 6 34-30-16-30 16 6-34L11 43l34-5Z" fill="currentColor"/></svg><span>Mint / 01</span></span></button><button class="gallery-opener" type="button" aria-label="Rose 카드 열기"><span class="gallery-visual" style="--tile:#fbadce"><svg viewBox="0 0 120 120" aria-hidden="true"><path d="m60 7 15 31 34 5-25 24 6 34-30-16-30 16 6-34L11 43l34-5Z" fill="currentColor"/></svg><span>Rose / 02</span></span></button><button class="gallery-opener" type="button" aria-label="Amber 카드 열기"><span class="gallery-visual" style="--tile:#ffd28c"><svg viewBox="0 0 120 120" aria-hidden="true"><path d="m60 7 15 31 34 5-25 24 6 34-30-16-30 16 6-34L11 43l34-5Z" fill="currentColor"/></svg><span>Amber / 03</span></span></button><button class="gallery-opener" type="button" aria-label="Violet 카드 열기"><span class="gallery-visual" style="--tile:#b5a1ff"><svg viewBox="0 0 120 120" aria-hidden="true"><path d="m60 7 15 31 34 5-25 24 6 34-30-16-30 16 6-34L11 43l34-5Z" fill="currentColor"/></svg><span>Violet / 04</span></span></button><button class="gallery-opener" type="button" aria-label="Sky 카드 열기"><span class="gallery-visual" style="--tile:#75d8ed"><svg viewBox="0 0 120 120" aria-hidden="true"><path d="m60 7 15 31 34 5-25 24 6 34-30-16-30 16 6-34L11 43l34-5Z" fill="currentColor"/></svg><span>Sky / 05</span></span></button><button class="gallery-opener" type="button" aria-label="Coral 카드 열기"><span class="gallery-visual" style="--tile:#fc7f8e"><svg viewBox="0 0 120 120" aria-hidden="true"><path d="m60 7 15 31 34 5-25 24 6 34-30-16-30 16 6-34L11 43l34-5Z" fill="currentColor"/></svg><span>Coral / 06</span></span></button></div></div><div class="controls"><label><input id="static-mode" type="checkbox">정적 보기</label></div><p class="readout" id="reading" aria-live="off"></p><dialog id="gallery-dialog" aria-labelledby="dialog-title"><div class="dialog-heading"><h3 id="dialog-title">선택한 카드</h3><button id="close-dialog" type="button" autofocus>닫기</button></div><div id="dialog-slot"></div></dialog></main>vendor/gsap-previews/sources/gsap-160507325ef2/style.css실행 안내·자료
*{box-sizing:border-box}body{background:#111522;color:#f5f2eb;font-family:system-ui,sans-serif;margin:0}button{font:inherit}.study{margin:0 auto;max-width:1100px;min-height:100vh;padding:clamp(20px,4vw,42px)}.study-label{color:#95efd2;font-size:12px;letter-spacing:.08em;margin:0 0 24px}header h2{font-size:clamp(24px,4vw,40px);letter-spacing:-.04em;margin:0 0 12px}header p{color:#aeb7c9;line-height:1.6;margin:0 0 24px;max-width:62ch}.controls{display:flex;flex-wrap:wrap;gap:8px;margin:20px 0}button{background:#26314b;border:1px solid #617394;border-radius:9px;color:#f5f2eb;cursor:pointer;padding:9px 14px}button:hover{background:#334261}button:focus-visible{outline:3px solid #95efd2;outline-offset:3px}button:disabled{cursor:default;opacity:.45}.stage{align-items:center;background:radial-gradient(ellipse at top,#243253,#141c2d);border:1px solid #3d4c68;border-radius:20px;display:flex;justify-content:center;min-height:220px;overflow:hidden;position:relative}.note{color:#aeb7c9;font-size:13px;line-height:1.5}.readout{color:#95efd2;font-family:ui-monospace,monospace;font-size:13px;min-height:2em}.stage svg{display:block;max-width:100%}code{font-family:ui-monospace,monospace}button[aria-pressed="true"]{background:#95efd2;color:#111522}
.study{padding:18px;max-width:960px}.study-label{margin-bottom:10px}header h2{font-size:clamp(22px,4vw,32px);margin-bottom:8px}header p{font-size:14px;margin-bottom:16px}.controls{align-items:center;gap:9px;margin:14px 0}.controls label{align-items:center;color:#cbd4e3;display:flex;flex-wrap:wrap;font-size:13px;gap:7px}.controls input[type=range]{accent-color:#95efd2;max-width:145px}.controls select{background:#26314b;border:1px solid #617394;border-radius:7px;color:#f5f2eb;font:inherit;padding:6px}.stage{min-height:180px}.readout{line-height:1.5;margin:8px 0}.small-code{background:#172036;border:1px solid #354258;border-radius:10px;color:#c3d1e7;font-size:12px;line-height:1.5;max-height:180px;overflow:auto;padding:12px;white-space:pre-wrap;word-break:break-word}.pair{display:flex;gap:12px;justify-content:center}.pair figure{flex:1;margin:0;max-width:300px;min-width:0;padding:8px}.pair figcaption{color:#aeb7c9;font-family:ui-monospace,monospace;font-size:12px;margin-bottom:6px;text-align:center}.pair svg{display:block;max-height:210px;width:100%}.tile-art{align-items:center;border-radius:14px;color:#152039;display:flex;justify-content:center}.tile-art svg{height:65%;width:65%}.menu-stage{min-height:196px;padding:18px}.menu-panels{display:flex;gap:10px;max-width:570px;width:100%}.menu-panel{align-items:center;background:linear-gradient(135deg,#95efd2,#75d8ed);border-radius:14px;color:#142137;display:flex;flex:1;flex-direction:column;font-weight:650;gap:10px;justify-content:center;min-height:135px;min-width:0;padding:12px}.menu-panel:nth-child(2){background:linear-gradient(135deg,#fbadce,#897dff)}.menu-panel:nth-child(3){background:linear-gradient(135deg,#ffd28c,#fc7f8e)}.menu-panel svg{height:58px;width:58px}.icon-bars{display:inline-flex;flex-direction:column;gap:5px;margin-right:7px;vertical-align:middle}.icon-bars span{background:currentColor;display:block;height:2px;width:17px}.endpoint-note{color:#aeb7c9;font-size:12px;line-height:1.5}button[hidden],[hidden]{display:none!important}@media(max-width:380px){.study{padding:14px}.controls label{max-width:100%}.menu-panels{gap:6px}.menu-panel{font-size:12px;padding:7px}.pair{gap:0}}
.gallery-stage{padding:12px}.tile-grid{display:grid;gap:10px;grid-template-columns:repeat(3,minmax(0,1fr));max-width:560px;width:100%}.gallery-opener{background:none;border:0;min-width:0;padding:0}.gallery-visual{align-items:center;background:var(--tile);border-radius:13px;color:#142137;display:flex;flex-direction:column;font-size:11px;font-weight:700;gap:7px;height:104px;justify-content:center;padding:10px;width:100%}.gallery-visual svg{height:56px;width:56px}.gallery-placeholder{display:block;max-width:100%}#gallery-dialog{background:#172036;border:1px solid #617394;border-radius:18px;color:#f5f2eb;margin:auto;max-height:90vh;max-width:min(80vw,560px);overflow:auto;padding:16px;width:560px}#gallery-dialog::backdrop{background:#080c16bb}.dialog-heading{align-items:center;display:flex;gap:12px;justify-content:space-between;margin-bottom:14px}.dialog-heading h3{font-size:16px;margin:0}.dialog-heading button{padding:8px 12px}.gallery-visual.expanded{height:min(50vh,300px);min-height:130px}.gallery-visual.expanded svg{height:70%;max-height:210px;width:70%}.gallery-visual.expanded>span{font-size:14px}@media(max-width:380px){.tile-grid{gap:6px}.gallery-visual{font-size:10px;height:95px;padding:7px}.gallery-visual svg{height:48px;width:48px}}vendor/gsap-previews/sources/gsap-160507325ef2/script.js실행 안내·자료
gsap.registerPlugin(Flip);
const q=selector=>document.querySelector(selector),qa=selector=>Array.from(document.querySelectorAll(selector));
const studyAbort=new AbortController(),studyCleanup=[];
const listen=(target,type,handler)=>target.addEventListener(type,handler,{signal:studyAbort.signal});
const preference=matchMedia('(prefers-reduced-motion: reduce)'),staticControl=q('#static-mode');
staticControl.checked=preference.matches;staticControl.disabled=preference.matches;
const isStatic=()=>staticControl.checked||preference.matches;
let applyMode=()=>{};
listen(staticControl,'change',()=>applyMode());
listen(preference,'change',()=>{staticControl.checked=preference.matches;staticControl.disabled=preference.matches;applyMode();});
listen(window,'pagehide',()=>{studyCleanup.forEach(cleanup=>cleanup());studyAbort.abort();});
const reading=text=>q('#reading').textContent=text;
const dialog=q('#gallery-dialog'),slot=q('#dialog-slot'),openers=qa('.gallery-opener');
let activeVisual=null,activeOpener=null,originalParent=null,originalNext=null,placeholder=null,modalTween=null,phase='closed',queuedClose=false;
function reflect(){reading('상태: '+phase+(queuedClose?' · 닫기 1회 대기':''));}
function restoreVisual(){if(!activeVisual)return;activeVisual.classList.remove('expanded');if(originalNext?.parentNode===originalParent)originalParent.insertBefore(activeVisual,originalNext);else originalParent.append(activeVisual);placeholder?.remove();placeholder=null;}
function finishClose(){phase='closed';queuedClose=false;const opener=activeOpener;activeVisual=null;activeOpener=null;originalParent=null;originalNext=null;modalTween=null;reflect();opener?.focus({preventScroll:true});}
function closeModal(){if(phase==='opening'){queuedClose=true;reflect();return;}if(phase!=='open')return;phase='closing';queuedClose=false;const state=Flip.getState(activeVisual);dialog.close();restoreVisual();reflect();if(isStatic()){gsap.set(activeVisual,{clearProps:'transform,opacity'});finishClose();return;}modalTween=Flip.from(state,{duration:.6,ease:'power2.inOut',onComplete:finishClose});}
function finishOpen(){phase='open';modalTween=null;reflect();if(queuedClose)closeModal();}
function openModal(opener){if(phase!=='closed')return;activeOpener=opener;activeVisual=opener.querySelector('.gallery-visual');originalParent=activeVisual.parentNode;originalNext=activeVisual.nextSibling;
const state=Flip.getState(activeVisual),bounds=activeVisual.getBoundingClientRect();placeholder=document.createElement('span');placeholder.className='gallery-placeholder';placeholder.style.width=bounds.width+'px';placeholder.style.height=bounds.height+'px';placeholder.setAttribute('aria-hidden','true');originalParent.insertBefore(placeholder,activeVisual);
phase='opening';queuedClose=false;dialog.showModal();activeVisual.classList.add('expanded');slot.append(activeVisual);q('#dialog-title').textContent=opener.getAttribute('aria-label').replace(' 열기','');q('#close-dialog').focus({preventScroll:true});reflect();if(isStatic()){finishOpen();return;}modalTween=Flip.from(state,{duration:.6,ease:'power2.inOut',onComplete:finishOpen});}
openers.forEach(opener=>listen(opener,'click',()=>openModal(opener)));listen(q('#close-dialog'),'click',closeModal);listen(dialog,'cancel',event=>{event.preventDefault();closeModal();});
applyMode=()=>{if(!modalTween)return;const running=modalTween;running.progress(1);running.kill();};
studyCleanup.push(()=>{modalTween?.kill();if(dialog.open)dialog.close();restoreVisual();});reflect();LICENSE실행 안내·자료
Locally authored companion HTML/CSS/control wiring: MIT License.
Copyright (c) 2026 StyleGallery 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.
The typed source-inputs.json and study-brief.json preserve official catalog, documentation and original library source pointers. This is independently authored API research, not a recovered CodePen source or documentation snippet. The local MIT notice does not assign new licenses to referenced third-party sources.
GSAP 3.15.0: Copyright 2026, GreenSock. All rights reserved. Subject to https://gsap.com/standard-license. Original library notices are preserved.
BEHIND THE EXAMPLE
이 장면을 만드는 원리
같은 시각 요소의 배치와 대화상자 수명
표현의 위치 연결과 초점·입력·DOM 복원 계약은 각각 명시해야 합니다.
- 이 예제에서는
- 독립 예제는 열기 전에 Flip.getState로 실제 요소를 측정한 뒤 같은 노드를 native dialog로 옮깁니다. 닫기는 열린 상태 측정→dialog.close→부모·형제 순서 복원→Flip.from 순서이며 완료 뒤 원래 버튼에 초점을 돌립니다. 등장 중 닫기는 한 번 대기하고 경쟁하는 열기는 무시합니다. 두 모달 ID는 공식 카탈로그의 동일한 Pen XWOeLEb를 가리켜 이 독립 구현을 공유하며, 원본의 모달 방식이나 초점 처리를 복구한 것은 아닙니다.
코드와 함께 확인하기
코드에서 찾기
function openModalscript.js대화상자를 열기 전에 측정하고 원래 위치에 크기 유지용 빈칸을 남깁니다.
function closeModalscript.js열린 상태의 기하를 측정하고 같은 작업에서 top layer를 닫은 뒤 실제 요소를 복원합니다.
직접 해보기
키보드로 카드를 열고 Escape로 닫습니다.
살펴볼 변화같은 노드가 같은 부모·형제 위치로 복원되고 빈칸이 제거되며 올바른 버튼에 초점이 돌아오는지 확인합니다.
열리는 중 닫기를 누르고 320px 폭과 정적 보기에서도 반복합니다.
살펴볼 변화닫기 요청 하나가 실행되고 잠긴 상태·고아 노드·대화상자 밖 입력이 남지 않는지 실제 브라우저에서 확인합니다.
