Add a restrained particle atmosphere inside one section with configurable shapes, density, gravity, wind, sway, rotation, recycling or settling, pointer disturb
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-ambient-section-particles-761b09deded9 ,按照其中的说明把「ambient-section-particles」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
Build particles as a bounded atmosphere layer, not as a page-wide screensaver. Keep the content primary and stop work when the effect cannot be seen.
Start with the least expensive renderer that preserves the desired shape language.
const particles = {
count: 54,
gravity: 7,
wind: -3,
sway: 16,
speed: [8, 18],
size: [4, 12],
opacity: [0.18, 0.62],
rotation: [-0.8, 0.8],
mode: "recycle",
pointerRadius: 110,
maxDpr: 2
};
Scale density by container area, then clamp it for mobile and low-power devices. Do not derive count from viewport width alone.
pointer-events: none; listen for pointer movement on the section.requestAnimationFrame loop for the whole layer.ResizeObserver; cap canvas backing resolution at min(devicePixelRatio, maxDpr).Support explicit end modes:
recycle: return particles above the section after exit.exit: remove particles after they leave the bounds.settle: resolve into a shallow visual pile with a strict height cap.static: render a deterministic still composition.Use IntersectionObserver to start only when the section is visible. Cancel animation frames when it exits or document.hidden becomes true. Resume from the current simulation state instead of spawning a second loop.
On teardown, disconnect observers, remove resize and pointer listeners, cancel the frame, and release renderer resources.
prefers-reduced-motion: reduce, render a sparse static arrangement or remove the layer.Test entry and exit pausing, background-tab recovery, fast resize, 390/768/1440 widths, device pixel ratio, pointer and touch input, reduced motion, section overflow, content focus, long text, route cleanup, and console errors. Confirm only one animation loop survives repeated mounts.
Use demo/index.html as the working reference and demo/PROMPT.md to recreate or remix it. Keep REFERENCES.md as the links-only implementation source list.