Framer Motion 애니메이션 원칙
Framer Motion의 선언적 React API를 사용하여 디즈니의 12가지 애니메이션 원칙을 모두 구현합니다.
1. 스쿼시와 스트레치 (Squash and Stretch)
<motion.div
animate={{ scaleX: [1, 1.2, 1], scaleY: [1, 0.8, 1] }}
transition={{ duration: 0.3, times: [0, 0.5, 1] }}
/>
2. 예비 동작 (Anticipation)
<motion.div
variants={{
idle: { y: 0, scaleY: 1 },
anticipate: { y: 10, scaleY: 0.9 },
jump: { y: -200 }
}}
initial="idle"
animate={["anticipate", "jump"]}
transition={{ duration: 0.5, times: [0, 0.2, 1] }}
/>
3. 스테이징 (Staging)
<motion.div animate={{ filter: "blur(3px)", opacity: 0.6 }} /> {/* 배경 */}
<motion.div animate={{ scale: 1.1, zIndex: 10 }} /> {/* 주인공 */}
4. 직진 동작 / 포즈 투 포즈 (Straight Ahead / Pose to Pose)
<motion.div
animate={{
x: [0, 100, 200, 300],
y: [0, -50, 0, -30]
}}
transition={{ duration: 1, ease: "easeInOut" }}
/>
5. 후속 동작과 중첩 동작 (Follow Through and Overlapping Action)
<motion.div animate={{ x: 200 }} transition={{ duration: 0.5 }}>
<motion.span
animate={{ x: 200 }}
transition={{ duration: 0.5, delay: 0.05 }} // 머리카락
/>
<motion.span
animate={{ x: 200 }}
transition={{ duration: 0.6, delay: 0.1 }} // 망토
/>
</motion.div>
6. 완만한 시작과 완만한 종료 (Slow In and Slow Out)
<motion.div
animate={{ x: 300 }}
transition={{
duration: 0.6,
ease: [0.42, 0, 0.58, 1] // easeInOut cubic-bezier
}}
/>
// 또는 "easeIn", "easeOut", "easeInOut" 사용 가능
7. 아크 (Arc)
<motion.div
animate={{
x: [0, 100, 200],
y: [0, -100, 0]
}}
transition={{ duration: 1, ease: "easeInOut" }}
/>
8. 보조 동작 (Secondary Action)
<motion.button
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
>
<motion.span
animate={{ rotate: [0, 10, -10, 0] }}
transition={{ duration: 0.3 }}
>
아이콘
</motion.span>
</motion.button>
9. 타이밍 (Timing)
const timings = {
fast: { duration: 0.15 },
normal: { duration: 0.3 },
slow: { duration: 0.6 },
spring: { type: "spring", stiffness: 300, damping: 20 }
};
10. 과장 (Exaggeration)
<motion.div
animate={{ scale: 1.5, rotate: 720 }}
transition={{
type: "spring",
stiffness: 200,
damping: 10 // 낮은 damping = 오버슈트
}}
/>
11. 입체감 (Solid Drawing)
<motion.div
style={{ perspective: 1000 }}
animate={{ rotateX: 45, rotateY: 30 }}
transition={{ duration: 0.5 }}
/>
12. 매력 (Appeal)
<motion.div
whileHover={{
scale: 1.02,
boxShadow: "0 20px 40px rgba(0,0,0,0.2)"
}}
transition={{ duration: 0.3 }}
/>
자식 요소 지연 애니메이션 (Stagger Children)
const container = {
hidden: { opacity: 0 },
show: {
opacity: 1,
transition: { staggerChildren: 0.1 }
}
};
<motion.ul variants={container} initial="hidden" animate="show">
{items.map(item => <motion.li variants={itemVariant} />)}
</motion.ul>
주요 Framer Motion 기능
animate- 대상 상태variants- 명명된 애니메이션 상태whileHover/whileTap- 제스처 애니메이션transition- 타이밍 및 이징AnimatePresence- 종료 애니메이션useAnimation- 프로그래매틱 제어layout- 레이아웃 변경 자동 애니메이션