CelebrationLayer
庆祝粒子,不依附任何角色。
共享引擎的 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——干活、庆祝、收敛
- 庆祝——干活、庆祝、收起来