GSAP 원본

Create physics-based effects

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

버튼 더 보기
ORIGINAL PREVIEW
Create physics-based effects 정적 미리보기

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

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

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

SOURCE FILES

원본 코드 읽기

6개 파일

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

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

<div id="emitter"></div>


<div class="text"><h4 class="braces">click for particles</h4></div>
vendor/gsap-previews/sources/gsap-b734be3dae81/style.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;
}
함께 쓰는 파일 4개 보기
vendor/gsap-previews/sources/gsap-b734be3dae81/script.js
파일 저장

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
});
vendor/gsap-previews/sources/gsap-b734be3dae81/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-b734be3dae81/adapters/script.js실행 안내·자료
파일 저장

window.__STYLEGALLERY_ASSETS__={};
gsap.registerPlugin(Draggable, InertiaPlugin, Physics2DPlugin);
const emitter = document.getElementById("emitter");
const container = document.createElement("div");
const emitterSize = 100;
const dotQuantity = 25;
const dotSizeMax = 20;
const dotSizeMin = 10;
const speed = 3;
const gravity = 3;
container.style.cssText = "position:absolute; left:0; top:0; overflow:visible; z-index:5000; pointer-events:none;";
document.body.appendChild(container);
const explosion = createExplosion(container);
function createExplosion(container2) {
  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);
    container2.appendChild(dot);
    const angle = Math.random() * Math.PI * 2;
    const length = Math.random() * (emitterSize / 2 - size / 2);
    gsap.set(dot, {
      x: Math.cos(angle) * length,
      y: Math.sin(angle) * length,
      width: size,
      height: size,
      xPercent: -50,
      yPercent: -50,
      force3D: true
    });
    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
    );
  }
  return tl;
}
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);
}
explode(emitter);
emitter.addEventListener("click", () => explode(emitter));
Draggable.create("#emitter", {
  inertia: true,
  bounds: window,
  edgeResistance: 0.7
});
LICENSE실행 안내·자료
파일 저장

<!--

Copyright (c) 2014 - GreenSock - https://codepen.io/GreenSock/pen/VwGdvj

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.