Princípios de Animação com Framer Motion
Implemente todos os 12 princípios de animação da Disney usando a API declarativa do Framer Motion para React.
1. Squash and Stretch (Comprimir e Esticar)
<motion.div
animate={{ scaleX: [1, 1.2, 1], scaleY: [1, 0.8, 1] }}
transition={{ duration: 0.3, times: [0, 0.5, 1] }}
/>
2. Anticipation (Antecipação)
<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 (Encenação)
<motion.div animate={{ filter: "blur(3px)", opacity: 0.6 }} /> {/* bg */}
<motion.div animate={{ scale: 1.1, zIndex: 10 }} /> {/* hero */}
4. Straight Ahead / Pose to Pose (Direto / Pose a 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 (Ação Contínua e Sobreposição)
<motion.div animate={{ x: 200 }} transition={{ duration: 0.5 }}>
<motion.span
animate={{ x: 200 }}
transition={{ duration: 0.5, delay: 0.05 }} // cabelo
/>
<motion.span
animate={{ x: 200 }}
transition={{ duration: 0.6, delay: 0.1 }} // capa
/>
</motion.div>
6. Slow In and Slow Out (Aceleração e Desaceleração)
<motion.div
animate={{ x: 300 }}
transition={{
duration: 0.6,
ease: [0.42, 0, 0.58, 1] // easeInOut cubic-bezier
}}
/>
// Ou use: "easeIn", "easeOut", "easeInOut"
7. Arc (Arco)
<motion.div
animate={{
x: [0, 100, 200],
y: [0, -100, 0]
}}
transition={{ duration: 1, ease: "easeInOut" }}
/>
8. Secondary Action (Ação Secundária)
<motion.button
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
>
<motion.span
animate={{ rotate: [0, 10, -10, 0] }}
transition={{ duration: 0.3 }}
>
Ícone
</motion.span>
</motion.button>
9. Timing (Tempo)
const temporizacoes = {
rapido: { duration: 0.15 },
normal: { duration: 0.3 },
lento: { duration: 0.6 },
mola: { type: "spring", stiffness: 300, damping: 20 }
};
10. Exaggeration (Exagero)
<motion.div
animate={{ scale: 1.5, rotate: 720 }}
transition={{
type: "spring",
stiffness: 200,
damping: 10 // baixo amortecimento = ultrapassa o alvo
}}
/>
11. Solid Drawing (Desenho Sólido)
<motion.div
style={{ perspective: 1000 }}
animate={{ rotateX: 45, rotateY: 30 }}
transition={{ duration: 0.5 }}
/>
12. Appeal (Apelo)
<motion.div
whileHover={{
scale: 1.02,
boxShadow: "0 20px 40px rgba(0,0,0,0.2)"
}}
transition={{ duration: 0.3 }}
/>
Stagger Children (Escalonar Filhos)
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>
Principais Recursos do Framer Motion
animate- Estado alvovariants- Estados de animação nomeadoswhileHover/whileTap- Animações por gestostransition- Temporização e easingAnimatePresence- Animações de saídauseAnimation- Controle programáticolayout- Animar automaticamente mudanças de layout