모션·인터랙션 / GSAP / Draggable · Inertia · Physics2D
Create physics-based effects
발사 지점을 드래그하고 클릭해 입자 물리 효과를 만듭니다.
미리보기 안의 버튼·입력·포인터로 모션을 확인하세요. 실행 방식은 아래 활용 메모를 참고하세요.
실행용 통합 HTML · 공식 GSAP 3.15.0
<!doctype html>
<!-- Source: https://codepen.io/GreenSock/pen/VwGdvj; archived original panels separately. Runtime: official GSAP 3.15.0. -->
<html lang="en" class=""><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Create physics-based effects</title>
<link rel="stylesheet" href="https://asset.wemashup.com/wp-content/uploads/wm-asset-library/gsap/shared/normalize-5.0.0.min.css">
<link rel="stylesheet" href="https://asset.wemashup.com/wp-content/uploads/wm-asset-library/gsap/shared/xxmzBrw.css">
<style>
body,
html {
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
body {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
min-height: 100vh;
}
#emitter {
border: dashed 2px var(--color-surface-white);
width: 100px;
height: 100px;
border-radius: 50%;
}
.dot {
background: var(--color-ui-gradient);
border-radius: 50%;
position: absolute;
}
.text {
margin-top: 3rem;
}
</style></head><body>
<div id="emitter"></div>
<div class="text"><h4 class="braces">click for particles</h4></div>
<script src="https://asset.wemashup.com/wp-content/uploads/wm-asset-library/gsap/shared/8626d7a5c995cf2e.js"></script>
<script src="https://asset.wemashup.com/wp-content/uploads/wm-asset-library/gsap/shared/gsap-3.15.0-gsap.min.js"></script>
<script src="https://asset.wemashup.com/wp-content/uploads/wm-asset-library/gsap/shared/gsap-3.15.0-Draggable.min.js"></script>
<script src="https://asset.wemashup.com/wp-content/uploads/wm-asset-library/gsap/shared/gsap-3.15.0-Physics2DPlugin.min.js"></script>
<script src="https://asset.wemashup.com/wp-content/uploads/wm-asset-library/gsap/shared/gsap-3.15.0-InertiaPlugin.min.js"></script>
<script>
gsap.registerPlugin(Draggable, InertiaPlugin, Physics2DPlugin);
// Elements & config
const emitter = document.getElementById("emitter");
// we'll put all the dots into this container so we can move the "explosion" anywhere
const container = document.createElement("div");
// Tweakables
const emitterSize = 100;
const dotQuantity = 25;
const dotSizeMax = 20;
const dotSizeMin = 10;
const speed = 3;
const gravity = 3;
// Setup the container
container.style.cssText = "position:absolute; left:0; top:0; overflow:visible; z-index:5000; pointer-events:none;";
document.body.appendChild(container);
// Build the explosion timeline once (reuse for performance)
const explosion = createExplosion(container);
function createExplosion(container) {
const tl = gsap.timeline();
for (let i = 0; i < dotQuantity; i++) {
const dot = document.createElement("div");
dot.className = "dot";
const size = gsap.utils.random(dotSizeMin, dotSizeMax, 1);
container.appendChild(dot);
const angle = Math.random() * Math.PI * 2; // radians
const length = Math.random() * (emitterSize / 2 - size / 2);
// Place dot within emitter and size it
gsap.set(dot, {
x: Math.cos(angle) * length,
y: Math.sin(angle) * length,
width: size,
height: size,
xPercent: -50,
yPercent: -50,
force3D: true
});
// Animate via Physics2D (GSAP plugin)
tl.to(
dot,
{
physics2D: {
angle: (angle * 180) / Math.PI,
velocity: (100 + Math.random() * 250) * speed,
gravity: 500 * gravity
},
duration: 1 + Math.random()
},
0
).to(
dot,
{
opacity: 0,
duration: 0.2,
ease: "power2.inOut"
},
0.7
);
// If you'd rather not do physics, you can swap the physics2D block for:
// { x: Math.cos(angle) * length * 6, y: Math.sin(angle) * length * 6, duration: 1 + Math.random() }
}
return tl;
}
// Move the container to the center of an element and play the explosion
function explode(element) {
const bounds = element.getBoundingClientRect();
gsap.set(container, { x: bounds.left + bounds.width / 2, y: bounds.top + bounds.height / 2 });
explosion.play(0);
}
// Go boom on load and on click
explode(emitter);
emitter.addEventListener("click", () => explode(emitter));
// Make the emitter draggable (requires InertiaPlugin for inertia:true)
Draggable.create("#emitter", {
inertia: true,
bounds: window,
edgeResistance: 0.7
});
</script></body></html>
원본 HTML
<div id="emitter"></div>
<div class="text"><h4 class="braces">click for particles</h4></div>원본 CSS
body,
html {
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
body {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
min-height: 100vh;
}
#emitter {
border: dashed 2px var(--color-surface-white);
width: 100px;
height: 100px;
border-radius: 50%;
}
.dot {
background: var(--color-ui-gradient);
border-radius: 50%;
position: absolute;
}
.text {
margin-top: 3rem;
}
원본 JavaScript
gsap.registerPlugin(Draggable, InertiaPlugin, Physics2DPlugin);
// Elements & config
const emitter = document.getElementById("emitter");
// we'll put all the dots into this container so we can move the "explosion" anywhere
const container = document.createElement("div");
// Tweakables
const emitterSize = 100;
const dotQuantity = 25;
const dotSizeMax = 20;
const dotSizeMin = 10;
const speed = 3;
const gravity = 3;
// Setup the container
container.style.cssText = "position:absolute; left:0; top:0; overflow:visible; z-index:5000; pointer-events:none;";
document.body.appendChild(container);
// Build the explosion timeline once (reuse for performance)
const explosion = createExplosion(container);
function createExplosion(container) {
const tl = gsap.timeline();
for (let i = 0; i < dotQuantity; i++) {
const dot = document.createElement("div");
dot.className = "dot";
const size = gsap.utils.random(dotSizeMin, dotSizeMax, 1);
container.appendChild(dot);
const angle = Math.random() * Math.PI * 2; // radians
const length = Math.random() * (emitterSize / 2 - size / 2);
// Place dot within emitter and size it
gsap.set(dot, {
x: Math.cos(angle) * length,
y: Math.sin(angle) * length,
width: size,
height: size,
xPercent: -50,
yPercent: -50,
force3D: true
});
// Animate via Physics2D (GSAP plugin)
tl.to(
dot,
{
physics2D: {
angle: (angle * 180) / Math.PI,
velocity: (100 + Math.random() * 250) * speed,
gravity: 500 * gravity
},
duration: 1 + Math.random()
},
0
).to(
dot,
{
opacity: 0,
duration: 0.2,
ease: "power2.inOut"
},
0.7
);
// If you'd rather not do physics, you can swap the physics2D block for:
// { x: Math.cos(angle) * length * 6, y: Math.sin(angle) * length * 6, duration: 1 + Math.random() }
}
return tl;
}
// Move the container to the center of an element and play the explosion
function explode(element) {
const bounds = element.getBoundingClientRect();
gsap.set(container, { x: bounds.left + bounds.width / 2, y: bounds.top + bounds.height / 2 });
explosion.play(0);
}
// Go boom on load and on click
explode(emitter);
emitter.addEventListener("click", () => explode(emitter));
// Make the emitter draggable (requires InertiaPlugin for inertia:true)
Draggable.create("#emitter", {
inertia: true,
bounds: window,
edgeResistance: 0.7
});
검증·권리 정보
- 실행 검증
- 데스크톱 실행 확인
- 검증 수준
- 샘플 실행
- 권리 확인
- 확인 필요
발사 지점을 드래그하고 클릭해 입자 물리 효과를 만듭니다.
Chromium 153 · 데스크톱 1280×900 · 격리 iframe에서 click #emitter 입력과 화면 변화 확인. 모바일·프로젝트 적용은 미검증.
원본 패널은 보존하고 실행용 문서에 공식 GSAP 3.15.0과 공통 의존성을 연결했습니다. 모션 감소 설정과 실제 프로젝트 적용은 별도로 확인하세요.
보관·활용 메모
GSAP Demo Hub의 공개 예제입니다. 원본 HTML·CSS·JavaScript와 설정, 시연 파일을 함께 보관했습니다. 통합 HTML은 공통 스타일과 실행 의존성을 연결한 파일이며 SCSS는 원본 컴파일 결과를 사용합니다.
구형 CodePen 전용 의존성을 그대로 배포하지 않고, 통합 실행에는 공식 GSAP 3.15.0을 연결했습니다. 원본 패널과 원본 설정은 ZIP에 별도로 보존되어 있습니다. 예제의 이미지·폰트 등 외부 소재 요청은 유지됩니다.
보관일 2026-10-27 · 공개 원본의 코드·제작자·설정을 보존했습니다. GSAP 엔진과 개별 코드·이미지·폰트의 사용 조건은 각각 확인해야 합니다. 자유 재배포 허용으로 판단한 자료가 아닙니다.