Skill站外收录 @skilllib/skill-2014279416996638723
animation-performance-retro
通过硬件加速与关键帧控制实现复古风格动画的流畅渲染,优先使用变换与透明度变化避免重排,结合状态条件触发脉冲、缩放等视觉反馈,确保像素艺术在交互中的高性能表现。
内容与媒体 AI 技能
Skills.MD
## Animation Performance for Retro UI
Optimize animations for smooth pixel art rendering and game-like interfaces.
### Hardware Acceleration
Use CSS transforms for GPU-accelerated animations:
```tsx
<div className="transition-transform hover:scale-110" />
<div className="translate-x-0 translate-y-0" />
```
**Avoid animating:**
- `width`, `height` (triggers layout)
- `margin`, `padding` (triggers layout)
- `top`, `left` (triggers layout)
**Prefer animating:**
- `transform` (GPU accelerated)
- `opacity` (GPU accelerated)
- `filter` (GPU accelerated)
### Pixelated Animations
Wrap animated SVGs in divs for hardware acceleration:
```tsx
function PixelSpinner() {
return (
<div className="animate-spin">
<svg viewBox="0 0 16 16">
<rect x="2" y="2" width="4" height="4" fill="currentColor" />
</svg>
</div>
);
}
```
### Loading States
Use pulse animations for retro loading indicators:
```tsx
function RetroSkeleton() {
return (
<div className="relative animate-pulse">
<div className="h-20 bg-muted" />
</div>
);
}
```
### Custom Retro Animations
Define pixel-art-specific animations:
```tsx
<div
className="retro animate-[blink_0.5s_step-end_infinite]"
style={{
textShadow: "1px 1px 0 #fff, -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff"
}}
>
LEVEL UP!
</div>
<style>{`
@keyframes blink {
0%, 100% { opacity: 1; }
50% { opacity: 0; }
}
`}</style>
```
### Conditional Animation States
Apply animations based on game state:
```tsx
<div
className={cn(
"transition-all duration-300",
health <= 25 && "animate-pulse bg-red-500/20",
isLevelUp && "animate-bounce"
)}
/>
```
### Radix UI Animations
Use Radix state-based animations for overlays:
```tsx
<DialogContent
className={cn(
"data-[state=open]:animate-in data-[state=closed]:animate-out",
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95"
)}
/>
<AccordionContent
className={cn(
"overflow-hidden data-[state=closed]:animate-accordion-up",
"data-[state=open]:animate-accordion-down"
)}
/>
```
### Key Principles
1. **Wrap SVGs** - Always wrap in div for hardware acceleration
2. **Use transforms** - Prefer `transform` over `top`/`left`
3. **Step animations** - Use `step-end` for pixel-art feel
4. **Conditional classes** - Apply animations based on game state
5. **Custom keyframes** - Define retro-specific animations
6. **Text shadows** - White shadow for legibility on colored backgrounds
### Performance Checklist
- [ ] Animated elements wrapped in divs
- [ ] No layout-triggering properties animated
- [ ] Loading states use `animate-pulse`
- [ ] Conditional animations properly gated
- [ ] Custom animations use step timing functions
### Reference Components
- `components/ui/8bit/spinner.tsx` - Animated spinner
- `components/ui/8bit/xp-bar.tsx` - Custom blink animation
- `components/ui/8bit/skeleton.tsx` - Loading skeleton
- `components/ui/8bit/accordion.tsx` - Radix state animations
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「animation-performance-retro」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次