adding-animations

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Adding Animations (MANDATORY)

添加动画(必须遵循)

Agent Workflow (MANDATORY)

Agent工作流(必须遵循)

Before ANY animation work, use
TeamCreate
to spawn 3 agents:
  1. fuse-ai-pilot:explore-codebase - Find existing Framer Motion patterns
  2. fuse-ai-pilot:research-expert - Verify latest Framer Motion v11 API
  3. Check existing animation timing conventions
After implementation, run fuse-ai-pilot:sniper for validation.

在开展任何动画工作之前,请使用
TeamCreate
生成3个Agent:
  1. fuse-ai-pilot:explore-codebase - 查找现有Framer Motion模式
  2. fuse-ai-pilot:research-expert - 验证最新Framer Motion v11 API
  3. 检查现有动画时间规范
实现完成后,运行fuse-ai-pilot:sniper进行验证。

Overview

概述

FeatureDescription
Framer MotionAnimation library (REQUIRED)
StaggerList/grid reveal patterns
Hover/TapInteractive micro-animations
Accessibilityprefers-reduced-motion support

特性说明
Framer Motion动画库(必须使用)
Stagger列表/网格渐显模式
Hover/Tap交互式微动画
Accessibility支持prefers-reduced-motion(减少动效偏好)

Critical Rules

核心规则

  1. Every component needs animation - No static components
  2. Stagger on lists - Container + item variants
  3. Hover on interactive - Buttons, cards, links
  4. Respect reduced motion - useReducedMotion hook
  5. Match existing patterns - Analyze codebase first

  1. 每个组件都需要添加动画 - 禁止静态组件
  2. 列表使用Stagger效果 - 容器+子元素变体
  3. 交互元素添加悬停效果 - 按钮、卡片、链接
  4. 尊重减少动效偏好 - 使用useReducedMotion钩子
  5. 匹配现有模式 - 先分析代码库

Timing Guidelines

时间规范

InteractionDurationEasing
Hover50-100msease-out
Button press100-150msease-out
Modal open200-300msease-out
Page transition300-400msease-in-out

交互类型时长缓动函数
悬停50-100msease-out
按钮按压100-150msease-out
模态框打开200-300msease-out
页面过渡300-400msease-in-out

Reference Guide

参考指南

Concepts

概念

TopicReferenceWhen to Consult
Motion Patternsmotion-patterns.mdFramer Motion examples
Buttonsbuttons-guide.mdHover/press timing
Cardscards-guide.mdCard hover effects
UI Designui-visual-design.mdMicro-interactions
Card Patternspatterns-cards.mdCard animations
Button Patternspatterns-buttons.mdButton animations
Navigationpatterns-navigation.mdNav animations
Micro-interactionspatterns-microinteractions.mdSmall details

主题参考文档适用场景
动效模式motion-patterns.mdFramer Motion示例
按钮buttons-guide.md悬停/按压时间规范
卡片cards-guide.md卡片悬停效果
UI设计ui-visual-design.md微交互
卡片模式patterns-cards.md卡片动画
按钮模式patterns-buttons.md按钮动画
导航patterns-navigation.md导航动画
微交互patterns-microinteractions.md细节动效

Quick Reference

快速参考

Container + Stagger

容器+Stagger效果

tsx
const container = {
  hidden: { opacity: 0 },
  show: { opacity: 1, transition: { staggerChildren: 0.1 } }
};

const item = {
  hidden: { opacity: 0, y: 20 },
  show: { opacity: 1, y: 0 }
};

<motion.div variants={container} initial="hidden" animate="show">
  <motion.div variants={item}>Item 1</motion.div>
  <motion.div variants={item}>Item 2</motion.div>
</motion.div>
tsx
const container = {
  hidden: { opacity: 0 },
  show: { opacity: 1, transition: { staggerChildren: 0.1 } }
};

const item = {
  hidden: { opacity: 0, y: 20 },
  show: { opacity: 1, y: 0 }
};

<motion.div variants={container} initial="hidden" animate="show">
  <motion.div variants={item}>Item 1</motion.div>
  <motion.div variants={item}>Item 2</motion.div>
</motion.div>

Hover Effects

悬停效果

tsx
// Card hover
<motion.div whileHover={{ y: -4 }} transition={{ duration: 0.2 }}>

// Button hover
<motion.button whileHover={{ scale: 1.02 }} whileTap={{ scale: 0.98 }}>
tsx
// Card hover
<motion.div whileHover={{ y: -4 }} transition={{ duration: 0.2 }}>

// Button hover
<motion.button whileHover={{ scale: 1.02 }} whileTap={{ scale: 0.98 }}>

Scroll Animation

滚动动画

tsx
<motion.div
  initial={{ opacity: 0, y: 40 }}
  whileInView={{ opacity: 1, y: 0 }}
  viewport={{ once: true, margin: "-100px" }}
/>
tsx
<motion.div
  initial={{ opacity: 0, y: 40 }}
  whileInView={{ opacity: 1, y: 0 }}
  viewport={{ once: true, margin: "-100px" }}
/>

Reduced Motion

减少动效支持

tsx
import { useReducedMotion } from "framer-motion";

const shouldReduce = useReducedMotion();
<motion.div
  animate={shouldReduce ? {} : { y: 0 }}
  transition={shouldReduce ? { duration: 0 } : { duration: 0.3 }}
/>
→ See motion-patterns.md for complete patterns

tsx
import { useReducedMotion } from "framer-motion";

const shouldReduce = useReducedMotion();
<motion.div
  animate={shouldReduce ? {} : { y: 0 }}
  transition={shouldReduce ? { duration: 0 } : { duration: 0.3 }}
/>
→ 完整模式请查看 motion-patterns.md

FORBIDDEN

禁止操作

tsx
// ❌ Random bouncing loops
animate={{ y: [0, -10, 0] }}
transition={{ repeat: Infinity }}

// ❌ Excessive effects
whileHover={{ scale: 1.2, rotate: 5 }}

// ❌ Slow animations
transition={{ duration: 1.5 }}

tsx
// ❌ 随机弹跳循环
animate={{ y: [0, -10, 0] }}
transition={{ repeat: Infinity }}

// ❌ 过度效果
whileHover={{ scale: 1.2, rotate: 5 }}

// ❌ 缓慢动画
transition={{ duration: 1.5 }}

Best Practices

最佳实践

DO

建议

  • Use container + item variants for lists
  • Add hover to all interactive elements
  • Respect prefers-reduced-motion
  • Keep animations under 400ms
  • Match existing timing patterns
  • 列表使用容器+子元素变体
  • 所有交互元素添加悬停效果
  • 尊重prefers-reduced-motion偏好
  • 动画时长控制在400ms以内
  • 匹配现有时间模式

DON'T

不建议

  • Create static components without animation
  • Use infinite looping animations
  • Make animations too slow (>400ms)
  • Forget accessibility considerations
  • Mix animation libraries (stick to Framer)
  • 创建无动画的静态组件
  • 使用无限循环动画
  • 动画过慢(超过400ms)
  • 忽略无障碍考虑
  • 混合使用多个动画库(坚持使用Framer)