popmotion
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePopmotion Animation Principles
Popmotion动画原则
Implement all 12 Disney animation principles using Popmotion's composable animation functions.
使用Popmotion的可组合动画函数实现全部12条迪士尼动画原则。
1. Squash and Stretch
1. 挤压与拉伸
javascript
import { animate } from "popmotion";
animate({
from: { scaleX: 1, scaleY: 1 },
to: { scaleX: 1.2, scaleY: 0.8 },
duration: 150,
onUpdate: ({ scaleX, scaleY }) => {
element.style.transform = `scaleX(${scaleX}) scaleY(${scaleY})`;
}
});javascript
import { animate } from "popmotion";
animate({
from: { scaleX: 1, scaleY: 1 },
to: { scaleX: 1.2, scaleY: 0.8 },
duration: 150,
onUpdate: ({ scaleX, scaleY }) => {
element.style.transform = `scaleX(${scaleX}) scaleY(${scaleY})`;
}
});2. Anticipation
2. 预备动作
javascript
// Wind up then action
animate({
from: 0,
to: 10,
duration: 200,
onUpdate: v => element.style.transform = `translateY(${v}px) scaleY(0.9)`,
onComplete: () => {
animate({
from: 10,
to: -200,
duration: 400,
ease: easeOut,
onUpdate: v => element.style.transform = `translateY(${v}px)`
});
}
});javascript
// Wind up then action
animate({
from: 0,
to: 10,
duration: 200,
onUpdate: v => element.style.transform = `translateY(${v}px) scaleY(0.9)`,
onComplete: () => {
animate({
from: 10,
to: -200,
duration: 400,
ease: easeOut,
onUpdate: v => element.style.transform = `translateY(${v}px)`
});
}
});3. Staging
3. 舞台呈现
javascript
animate({
from: 1,
to: 0.6,
onUpdate: v => bg.style.opacity = v
});
animate({
from: 1,
to: 1.1,
onUpdate: v => hero.style.transform = `scale(${v})`
});javascript
animate({
from: 1,
to: 0.6,
onUpdate: v => bg.style.opacity = v
});
animate({
from: 1,
to: 1.1,
onUpdate: v => hero.style.transform = `scale(${v})`
});4. Straight Ahead / Pose to Pose
4. 逐帧动画/关键帧动画
javascript
import { keyframes } from "popmotion";
keyframes({
values: [
{ x: 0, y: 0 },
{ x: 100, y: -50 },
{ x: 200, y: 0 },
{ x: 300, y: -30 }
],
duration: 1000,
onUpdate: ({ x, y }) => {
element.style.transform = `translate(${x}px, ${y}px)`;
}
});javascript
import { keyframes } from "popmotion";
keyframes({
values: [
{ x: 0, y: 0 },
{ x: 100, y: -50 },
{ x: 200, y: 0 },
{ x: 300, y: -30 }
],
duration: 1000,
onUpdate: ({ x, y }) => {
element.style.transform = `translate(${x}px, ${y}px)`;
}
});5. Follow Through and Overlapping Action
5. 跟随动作与重叠动作
javascript
animate({ from: 0, to: 200, duration: 500,
onUpdate: v => body.style.transform = `translateX(${v}px)` });
animate({ from: 0, to: 200, duration: 500, elapsed: -50, // delay
onUpdate: v => hair.style.transform = `translateX(${v}px)` });
animate({ from: 0, to: 200, duration: 600, elapsed: -100,
onUpdate: v => cape.style.transform = `translateX(${v}px)` });javascript
animate({ from: 0, to: 200, duration: 500,
onUpdate: v => body.style.transform = `translateX(${v}px)` });
animate({ from: 0, to: 200, duration: 500, elapsed: -50, // delay
onUpdate: v => hair.style.transform = `translateX(${v}px)` });
animate({ from: 0, to: 200, duration: 600, elapsed: -100,
onUpdate: v => cape.style.transform = `translateX(${v}px)` });6. Slow In and Slow Out
6. 缓入缓出
javascript
import { animate, easeInOut, easeIn, easeOut } from "popmotion";
animate({
from: 0,
to: 300,
duration: 600,
ease: easeInOut,
onUpdate: v => element.style.transform = `translateX(${v}px)`
});javascript
import { animate, easeInOut, easeIn, easeOut } from "popmotion";
animate({
from: 0,
to: 300,
duration: 600,
ease: easeInOut,
onUpdate: v => element.style.transform = `translateX(${v}px)`
});7. Arc
7. 弧线运动
javascript
keyframes({
values: [
{ x: 0, y: 0 },
{ x: 100, y: -100 },
{ x: 200, y: 0 }
],
duration: 1000,
ease: easeInOut,
onUpdate: ({ x, y }) => {
element.style.transform = `translate(${x}px, ${y}px)`;
}
});javascript
keyframes({
values: [
{ x: 0, y: 0 },
{ x: 100, y: -100 },
{ x: 200, y: 0 }
],
duration: 1000,
ease: easeInOut,
onUpdate: ({ x, y }) => {
element.style.transform = `translate(${x}px, ${y}px)`;
}
});8. Secondary Action
8. 次要动作
javascript
// Primary action triggers secondary
animate({
from: 1, to: 1.1, duration: 200,
onUpdate: v => button.style.transform = `scale(${v})`,
onComplete: () => {
animate({
from: 0, to: 15, duration: 150,
onUpdate: v => icon.style.transform = `rotate(${v}deg)`
});
}
});javascript
// Primary action triggers secondary
animate({
from: 1, to: 1.1, duration: 200,
onUpdate: v => button.style.transform = `scale(${v})`,
onComplete: () => {
animate({
from: 0, to: 15, duration: 150,
onUpdate: v => icon.style.transform = `rotate(${v}deg)`
});
}
});9. Timing
9. 时间节奏
javascript
import { spring } from "popmotion";
// Fast
animate({ from: 0, to: 100, duration: 150 });
// Spring physics
spring({
from: 0,
to: 100,
stiffness: 300,
damping: 20,
onUpdate: v => element.style.transform = `translateX(${v}px)`
});
// Slow
animate({ from: 0, to: 100, duration: 800, ease: easeOut });javascript
import { spring } from "popmotion";
// Fast
animate({ from: 0, to: 100, duration: 150 });
// Spring physics
spring({
from: 0,
to: 100,
stiffness: 300,
damping: 20,
onUpdate: v => element.style.transform = `translateX(${v}px)`
});
// Slow
animate({ from: 0, to: 100, duration: 800, ease: easeOut });10. Exaggeration
10. 夸张表现
javascript
spring({
from: { scale: 1, rotate: 0 },
to: { scale: 1.5, rotate: 720 },
stiffness: 200,
damping: 10, // low = overshoot
onUpdate: ({ scale, rotate }) => {
element.style.transform = `scale(${scale}) rotate(${rotate}deg)`;
}
});javascript
spring({
from: { scale: 1, rotate: 0 },
to: { scale: 1.5, rotate: 720 },
stiffness: 200,
damping: 10, // low = overshoot
onUpdate: ({ scale, rotate }) => {
element.style.transform = `scale(${scale}) rotate(${rotate}deg)`;
}
});11. Solid Drawing
11. 扎实构图
javascript
animate({
from: { rotateX: 0, rotateY: 0 },
to: { rotateX: 45, rotateY: 30 },
duration: 500,
onUpdate: ({ rotateX, rotateY }) => {
box.style.transform = `perspective(1000px) rotateX(${rotateX}deg) rotateY(${rotateY}deg)`;
}
});javascript
animate({
from: { rotateX: 0, rotateY: 0 },
to: { rotateX: 45, rotateY: 30 },
duration: 500,
onUpdate: ({ rotateX, rotateY }) => {
box.style.transform = `perspective(1000px) rotateX(${rotateX}deg) rotateY(${rotateY}deg)`;
}
});12. Appeal
12. 吸引力
javascript
animate({
from: 1,
to: 1.02,
duration: 300,
ease: easeOut,
onUpdate: v => {
card.style.transform = `scale(${v})`;
card.style.boxShadow = `0 ${20*v}px 40px rgba(0,0,0,${0.2*v})`;
}
});javascript
animate({
from: 1,
to: 1.02,
duration: 300,
ease: easeOut,
onUpdate: v => {
card.style.transform = `scale(${v})`;
card.style.boxShadow = `0 ${20*v}px 40px rgba(0,0,0,${0.2*v})`;
}
});Key Popmotion Features
Popmotion核心特性
- - Tween animations
animate() - - Physics-based spring
spring() - - Multi-step animations
keyframes() - - Momentum/inertia
decay() - ,
easeIn,easeOut- Easing functionseaseInOut - Composable functions - mix and pipe
- Framework agnostic
- Powers Framer Motion under the hood
- - 补间动画
animate() - - 基于物理的弹簧动画
spring() - - 多步骤动画
keyframes() - - 动量/惯性动画
decay() - ,
easeIn,easeOut- 缓动函数easeInOut - 可组合函数 - 混合与管道调用
- 框架无关
- 是Framer Motion的底层驱动