ConfettiLayer
庆祝粒子,不依附任何角色。
共享引擎的 ticker
这一层使用角色同一套粒子系统,并订阅同一个共享的 requestAnimationFrame,所以给页面加上庆祝不需要额外的动画循环。
物理
碎片从身体半径的环上发射,带向上偏差,然后在重力下下落并逐帧阻尼。寿命在 0.45 到 0.85 秒之间。大约六分之一是星星,其余是点或沿速度拉长的条。
不透明度不是线性的——寿命的前十分之一快速淡入,然后按幂曲线淡出,读起来像碎片远去而不是溶解。
减少动态效果
读者偏好减少动态效果时,burst() 是空操作。从中心向外辐射的粒子是前庭刺激,所以被抑制而不是仅仅变慢。
API
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
className | string | — | — |
radius | number | 114 | Radius the confetti launches from, in viewBox units rather than pixels — the layer scales with its box, so this is a proportion of the character it sits over and does not change when the box does. Deliberately not `radiusPx`. |
ref | Ref<ConfettiHandle> | — | — |
style | CSSProperties | — | — |
接下来
- usePublishMark——干活、庆祝、收敛
- 庆祝——干活、庆祝、收起来