emilkowal-animations
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseEmil Kowalski Animation Best Practices
Emil Kowalski 动画最佳实践
Comprehensive animation guide for web interfaces based on Emil Kowalski's teachings, open-source libraries (Sonner, Vaul), and his animations.dev course. Contains 43 rules across 7 categories, prioritized by impact.
基于Emil Kowalski的教学内容、开源库(Sonner、Vaul)以及他的animations.dev课程,这份指南是面向Web界面的全面动效指导。包含7个分类下的43条规则,按影响优先级排序。
When to Apply
适用场景
Reference these guidelines when:
- Adding animations to React components
- Choosing easing curves or timing values
- Implementing gesture-based interactions (swipe, drag)
- Building toast notifications or drawer components
- Optimizing animation performance
- Ensuring animation accessibility
在以下场景中参考本指南:
- 为React组件添加动画
- 选择缓动曲线或时长参数
- 实现基于手势的交互(滑动、拖拽)
- 构建提示框(toast)或抽屉组件
- 优化动画性能
- 确保动画的可访问性
Rule Categories by Priority
按优先级排序的规则分类
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Easing Selection | CRITICAL | |
| 2 | Timing & Duration | CRITICAL | |
| 3 | Property Selection | HIGH | |
| 4 | Transform Techniques | HIGH | |
| 5 | Interaction Patterns | MEDIUM-HIGH | |
| 6 | Strategic Animation | MEDIUM | |
| 7 | Accessibility & Polish | MEDIUM | |
| 优先级 | 分类 | 影响程度 | 前缀 |
|---|---|---|---|
| 1 | 缓动选择 | 关键 | |
| 2 | 时长与计时 | 关键 | |
| 3 | 属性选择 | 高 | |
| 4 | 变换技巧 | 高 | |
| 5 | 交互模式 | 中高 | |
| 6 | 动效策略 | 中 | |
| 7 | 可访问性与细节优化 | 中 | |
Quick Reference
快速参考
1. Easing Selection (CRITICAL)
1. 缓动选择(关键)
- - Use ease-out as your default easing
ease-out-default - - Use custom cubic-bezier over built-in CSS
ease-custom-curves - - Use ease-in-out for on-screen movement
ease-in-out-onscreen - - Use spring animations for natural motion
ease-spring-natural - - Use iOS-style easing for drawer components
ease-ios-drawer - - Match easing to animation context
ease-context-matters
- - 使用ease-out作为默认缓动效果
ease-out-default - - 优先使用自定义cubic-bezier而非CSS内置缓动
ease-custom-curves - - 屏幕内移动使用ease-in-out缓动
ease-in-out-onscreen - - 使用弹簧动画实现自然动效
ease-spring-natural - - 抽屉组件使用iOS风格缓动
ease-ios-drawer - - 缓动效果需匹配动画场景
ease-context-matters
2. Timing & Duration (CRITICAL)
2. 时长与计时(关键)
- - Keep UI animations under 300ms
timing-300ms-max - - Faster animations improve perceived performance
timing-faster-better - - Use asymmetric timing for press and release
timing-asymmetric - - Delay initial tooltips, instant subsequent ones
timing-tooltip-delay - - Use 500ms duration for drawer animations
timing-drawer-500ms
- - UI动画时长不超过300ms
timing-300ms-max - - 更快的动画提升感知性能
timing-faster-better - - 按压和释放使用非对称时长
timing-asymmetric - - 首次提示框添加延迟,后续即时显示
timing-tooltip-delay - - 抽屉动画使用500ms时长
timing-drawer-500ms
3. Property Selection (HIGH)
3. 属性选择(高)
- - Animate only transform and opacity
props-transform-opacity - - Use hardware-accelerated animations when main thread is busy
props-hardware-accelerated - - Use will-change to prevent 1px shift
props-will-change - - Avoid CSS variables for drag animations
props-avoid-css-variables - - Use clip-path for layout-free reveals
props-clip-path-performant
- - 仅对transform和opacity属性执行动画
props-transform-opacity - - 主线程繁忙时使用硬件加速动画
props-hardware-accelerated - - 使用will-change避免1px偏移
props-will-change - - 拖拽动画避免使用CSS变量
props-avoid-css-variables - - 使用clip-path实现无布局变化的显示效果
props-clip-path-performant
4. Transform Techniques (HIGH)
4. 变换技巧(高)
- - Scale buttons to 0.97 on press
transform-scale-097 - - Never animate from scale(0)
transform-never-scale-zero - - Use percentage values for translateY
transform-percentage-translate - - Make animations origin-aware
transform-origin-aware - - Scale transforms affect children
transform-scale-children - - Use preserve-3d for 3D transform effects
transform-3d-preserve
- - 按钮按压时缩放到0.97
transform-scale-097 - - 切勿从scale(0)开始动画
transform-never-scale-zero - - translateY使用百分比值
transform-percentage-translate - - 动画需考虑变换原点
transform-origin-aware - - 缩放变换会影响子元素
transform-scale-children - - 使用preserve-3d实现3D变换效果
transform-3d-preserve
5. Interaction Patterns (MEDIUM-HIGH)
5. 交互模式(中高)
- - Make animations interruptible
interact-interruptible - - Use momentum-based dismissal
interact-momentum-dismiss - - Damp drag at boundaries
interact-damping - - Resolve scroll and drag conflicts
interact-scroll-drag-conflict - - Implement velocity-aware snap points
interact-snap-points - - Allow upward drag with friction
interact-friction-upward - - Use pointer capture for drag operations
interact-pointer-capture
- - 动画需支持中断
interact-interruptible - - 使用基于动量的关闭方式
interact-momentum-dismiss - - 边界处拖拽添加阻尼效果
interact-damping - - 解决滚动与拖拽的冲突
interact-scroll-drag-conflict - - 实现速度感知的吸附点
interact-snap-points - - 允许带摩擦力的向上拖拽
interact-friction-upward - - 拖拽操作使用指针捕获
interact-pointer-capture
6. Strategic Animation (MEDIUM)
6. 动效策略(中)
- - Never animate keyboard-initiated actions
strategy-keyboard-no-animate - - Consider interaction frequency before animating
strategy-frequency-matters - - Every animation must have a purpose
strategy-purpose-required - - Provide immediate feedback on all actions
strategy-feedback-immediate - - Marketing sites are the exception
strategy-marketing-exception
- - 切勿为键盘触发的操作添加动画
strategy-keyboard-no-animate - - 添加动画前考虑交互频率
strategy-frequency-matters - - 每个动画必须有明确目的
strategy-purpose-required - - 所有操作需提供即时反馈
strategy-feedback-immediate - - 营销类网站除外
strategy-marketing-exception
7. Accessibility & Polish (MEDIUM)
7. 可访问性与细节优化(中)
- - Respect prefers-reduced-motion
polish-reduced-motion - - Use opacity as reduced motion fallback
polish-opacity-fallback - - Use useReducedMotion hook in Framer Motion
polish-framer-hook - - Don't remove all animation for reduced motion
polish-dont-remove-all - - Use blur to bridge animation states
polish-blur-bridge - - Use clip-path for tab transitions
polish-clip-path-tabs - - Implement toast stacking with scale and offset
polish-toast-stacking - - Trigger scroll animations at appropriate threshold
polish-scroll-reveal - - Fill gaps between hoverable elements
polish-hover-gap-fill - - Stagger child animations for orchestration
polish-stagger-children
- - 尊重prefers-reduced-motion设置
polish-reduced-motion - - 使用opacity作为减少动效的降级方案
polish-opacity-fallback - - 在Framer Motion中使用useReducedMotion钩子
polish-framer-hook - - 减少动效时不要移除所有动画
polish-dont-remove-all - - 使用模糊效果衔接动画状态
polish-blur-bridge - - 使用clip-path实现标签页过渡
polish-clip-path-tabs - - 实现带缩放和偏移的提示框堆叠
polish-toast-stacking - - 在合适的阈值触发滚动显示动画
polish-scroll-reveal - - 填充可悬停元素间的间隙
polish-hover-gap-fill - - 子元素动画使用 stagger 编排
polish-stagger-children
Key Values Reference
关键参数参考
| Value | Usage |
|---|---|
| iOS-style drawer/sheet animation |
| Button press feedback |
| Minimum enter scale (never scale(0)) |
| Standard UI transition |
| Maximum duration for UI animations |
| Drawer animation duration |
| Velocity threshold for momentum dismiss |
| Scroll-reveal viewport threshold |
| Toast stack offset |
| 参数值 | 用途 |
|---|---|
| iOS风格抽屉/面板动画 |
| 按钮按压反馈 |
| 最小进入缩放比例(切勿使用scale(0)) |
| 标准UI过渡 |
| UI动画最长时长 |
| 抽屉动画时长 |
| 动量关闭的速度阈值 |
| 滚动显示的视口阈值 |
| 提示框堆叠偏移量 |
Reference Files
参考文件
| File | Description |
|---|---|
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |
| 文件 | 描述 |
|---|---|
| references/_sections.md | 分类定义与排序规则 |
| assets/templates/_template.md | 新规则模板 |
| metadata.json | 版本与参考信息 |