跳到正文
Skillpedia
网站与界面(前端)7.2k · #13395

ambient-section-particles

它能做什么

这个技能指导 AI 智能体在网页的一部分中添加轻量、有边界的粒子效果。适合希望营造雪花或花瓣等氛围、同时保持文字易读的设计师。

适用场景

  • ✓某个板块需要雪花、树叶或火星等柔和氛围效果的时候。
  • ✓你想让粒子对鼠标有轻微反应,同时不阻挡点击的时候。
  • ✓效果需要在慢速设备上停止,并为偏好减少动态效果的访客提供支持的时候。

技能链接

https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/ambient-section-particles/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/ambient-section-particles/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请在我春季促销页面的页眉添加几片柔和飘落的花瓣,但要保持文字清晰。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会选择一种简单的绘制方法,设置适度的粒子数量,并把它们放在内容后方。当效果不可见时它会暂停,并为偏好减少动态效果的访客提供静态版本。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Ambient Section Particles

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.

Choose the renderer

  • Use canvas for roughly 40 or more small particles, frequent motion, pointer forces, or simple procedural shapes.
  • Use DOM or inline SVG for a small count of branded fragments that need individual styling or semantic labels.
  • Use WebGL only for thousands of particles, depth, shaders, or real 3D behavior. Cap device pixel ratio and provide a static fallback.

Start with the least expensive renderer that preserves the desired shape language.

Define one configuration

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.

Layer the section

  1. Give the section a positioning context and clip overflow when particles should remain bounded.
  2. Place the particle surface behind content but above the background.
  3. Set the layer to pointer-events: none; listen for pointer movement on the section.
  4. Reserve a quiet content zone or lower density behind long text and controls.
  5. Keep controls and links in normal DOM stacking with visible focus.

Run the simulation

  • Seed particles inside or just above the container bounds.
  • Update gravity, wind, phase-based sway, rotation, opacity, and position from elapsed time.
  • Clamp large time deltas after background tabs or stalled frames.
  • Use one requestAnimationFrame loop for the whole layer.
  • Resize with ResizeObserver; cap canvas backing resolution at min(devicePixelRatio, maxDpr).
  • For pointer disturbance, apply a small distance-based force and let particles settle back naturally. Never attach a listener per particle.

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.

Stop invisible work

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.

Respect the reader

  • Under prefers-reduced-motion: reduce, render a sparse static arrangement or remove the layer.
  • Keep particles decorative and hidden from assistive technology.
  • Control opacity and contrast so motion never crosses the legibility threshold.
  • Avoid full-screen pointer repulsion, rapid direction changes, flashes, and large objects crossing form controls.
  • Pause decorative motion while a modal or critical task in the section is active when it competes for attention.

Verify

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.

常见问题

粒子会挡住按钮吗?

不会。技能把图层设置为让指针事件穿透,并要求在长文字后方留出安静区域。

使用多少粒子?

数量与板块面积成比例,并为手机和低功耗设备设置了上限。

我可以使用品牌图形吗?

可以。技能允许使用图标或品牌碎片等形状,只要它们与板块的氛围相符。

详情

作者的原始描述

Add a restrained particle atmosphere inside one section with configurable shapes, density, gravity, wind, sway, rotation, recycling or settling, pointer disturbance, visibility pausing, responsive limits, and reduced-motion fallbacks. Use for petals, leaves, snow, sparks, confetti, dots, paper, icons, or brand fragments that support a section's mood without obscuring content.

repo: MengTo/Skills

热度

GitHub 星标
7.2k
排名
#13395
许可证
MIT
更新时间
2026/11/1

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能