motion-animate
設計決定一個幀是否好。動畫決定它是否看起來昂貴。 相同的構圖如果用線性緩動與同時進場,就會被讀為隨機生成的;而套用下列語彙,則會被讀為經手創作的。
引擎配方:附錄 A、附錄 B。
四大法則
- 沒有線性。 每個屬性都應該有緩動。線性運動在物理世界中不存在,眼睛能立刻察覺。
- 沒有同時進場。 元素以 60–120 毫秒間隔有順序地進場。同時進場是最明顯的生成痕跡。
- 攝影機從未完全靜止。 每個場景都有一個緩慢的連續推鏡或漂移。靜止的幀讀起來像幻燈片。
- 沒有機械式節奏。 要變化持續時間與剪輯間隔。每拍都 1 秒的均勻節奏,無論單拍多好,都感覺像自動化。
時序表
數值以 30fps 為基準;60fps 請等比縮放。時間單位為毫秒。
| 元素 | 持續時間 | 錯開時間 | 緩動曲線 |
|---|---|---|---|
| 文字行中的字詞 | 400–550 | 60–90 | out-expo / power3.out |
| 文字行(單一單位) | 500–650 | 120–180 | out-cubic / power2.out |
| 圖示 / 小 UI 元素 | 350–450 | 80–120 | out-back(回彈不超過 1.06) |
| 面板 / 卡片 | 550–700 | 140–200 | out-quint / power4.out |
| Hero 物件縮放進場 | 700–900 | — | out-expo |
| Hero 物件滑入進場 | 650–850 | — | out-quint |
| 線條 / 筆觸描繪 | 600–1000 | — | in-out-cubic |
| 攝影機推位(每場景) | 整個場景長度 | — | out-sine,若非常慢則接近線性 |
| 退場(任何元素) | 250–350 | 40–60 | in-cubic |
退場總是比進場快,大約快一半。對稱的退場動畫會感覺遲緩。
核心動作
文字 — 逐字彈出模糊淡入
招牌動作。每個屬性同時動畫,逐字,錯開進場。
y: +18px → 0
blur: 12px → 0
opacity: 0 → 1
ease: out-expo,持續時間 480ms,錯開 70ms
可選加 scale: 0.96 → 1。不要加旋轉。不要回彈。
對於長句,按字詞錯開,不要按字元 — 字元錯開會像打字機噱頭且耗時過長。字元錯開保留給單個短的重點字。
重點字
使用相同動畫,但 比其鄰近字詞延遲 120–200ms,並多加一個屬性 — 顏色變化、縮放到 1.04,或在字後掃入一個高亮條。它應該最後一個著陸且著陸方式不同。
圖示和 UI
彈出淡入:scale 0.7 → 1,opacity 0 → 1,out-back,回彈上限 1.06。超過 1.1 就會顯得太廉價。
順序規則:先進入錨點元素,然後是其依賴項。卡片先進,然後是它的圖示,然後是它的標籤。絕不反過來,也絕不一起進。
面板 / 卡片 / 玻璃效果
y: +40 → 0,opacity 0 → 1,out-quint,600ms,堆疊時錯開 160ms。再加一個掃光高亮,在面板著陸後 150ms 滑過面板 — 面板到達,然後被光照到。
Hero 物件
兩種選擇,按原型選擇:
- 縮放進場:
scale 1.25 → 1.00加rotate 3° → 0°,out-expo,800ms。感覺像它落定到位。 - 滑入進場:從畫框外滑入,帶 2° 傾斜後歸零,
out-quint,750ms。感覺像被送達。
投影和裁切紋理必須跟隨 hero 物件,所以它們要和 hero 綁定。未綁定的投影獨立滑動是嚴重的錯誤。
筆觸 / 線條描繪
將路徑長度從 0 動畫到 100%,in-out-cubic,600–1000ms。進場和退場都要緩動 — 從全速開始的描繪會很機械。用於將標籤連接到主體、為重點字加底線,或描繪圖表。
攝影機
每個場景下,選擇一種:
- 推近:
scale 1.00 → 1.08在整個節拍期間,out-sine。 - 拉遠:
scale 1.12 → 1.00,開始較快,然後穩定。 - 漂移:
x或y平移 2–4%,在整個節拍期間完成。
防抖契約:
- 動畫一個包裝元素,絕不動畫控制佈局或裁剪的元素。
- 只使用
transform— 絕不使用top/left/width/height。 - 將移動圖層縮放到超過畫框約 6%,確保邊緣永遠不會暴露。
- 設定
will-change: transform並強制 GPU 合成。 - 保持總位移小。大的攝影機移動會放大每個捨入誤差。
場景間過渡
- 硬切搭配音效衝擊 — 預設。設計幀之間的交叉淡化會模糊兩者。
- 透過縮放過渡 — 一個元素縮放至充滿畫面,下一個場景在其中顯現。
- 透過形狀擦拭 — 一個圓形或面板縮放超過畫框邊緣,帶入下一個場景。
不要在兩個設計構圖之間交叉淡化。不要使用預設過渡效果。
禁止
- 任何可見物體使用線性緩動。
- 回彈超過 1.1(例外:有意為之的趣味 SaaS/產品風格,且要一致使用)。
- 所有元素在同一幀進場。
- 整個剪輯中節拍長度均勻。
repeat: -1或任何無限循環 — 渲染是幀採樣的,必須是確定性的。Math.random(),Date.now()或網路請求在構圖內部。相同輸入必須每次都產生相同幀。- 在框架已經控制的包裝器上套用動畫(見附錄 B §clip 規則)。
自我檢查
以 0.25 倍速播放渲染。問:
- 有沒有東西突然開始或停止?→ 缺少緩動。
- 所有東西一起著陸?→ 缺少錯開。
- 幀是否曾完全靜止?→ 缺少攝影機。
- 連續的節拍聽起來像鼓點?→ 持續時間太過均勻。
- 移動圖層的邊緣是否曾暴露?→ 未足夠放大。
附錄 A — Remotion 配方
基於幀,本質上確定性。所有時序從 useCurrentFrame() 推導。
輔助函數:時間以毫秒為單位,而非幀
以幀為單位編寫會將 fps 寫死。進行轉換。
import {useVideoConfig, useCurrentFrame, interpolate, Easing} from 'remotion';
const useMs = () => {
const {fps} = useVideoConfig();
return (ms: number) => (ms / 1000) * fps;
};
緩動對照表
時序表中的名稱,以 Remotion 術語表示:
Easing.out(Easing.exp) // out-expo
Easing.out(Easing.cubic) // out-cubic
Easing.out(Easing.quad) // out-quad
Easing.out(Easing.poly(4)) // out-quint 近似
Easing.inOut(Easing.cubic) // in-out-cubic
Easing.out(Easing.sin) // out-sine
Easing.in(Easing.cubic) // in-cubic (退場)
Easing.bezier(0.16, 1, 0.3, 1) // 主力 — 近似 out-expo
對於回彈,優先使用 spring 而不是 Easing.back — 更容易保持微妙。
import {spring} from 'remotion';
const s = spring({frame, fps, config: {damping: 200, stiffness: 120, mass: 0.6}});
// damping 200 = 無可見回彈。降至 ~14 可產生輕微穩定效果。
文字 — 逐字彈出模糊淡入
const Words: React.FC<{text: string; delay?: number}> = ({text, delay = 0}) => {
const frame = useCurrentFrame();
const ms = useMs();
const STAGGER = ms(70);
const DUR = ms(480);
return (
<span style={{display: 'inline-flex', flexWrap: 'wrap', gap: '0.28em'}}>
{text.split(' ').map((word, i) => {
const local = frame - ms(delay) - i * STAGGER;
const p = interpolate(local, [0, DUR], [0, 1], {
extrapolateLeft: 'clamp',
extrapolateRight: 'clamp',
easing: Easing.bezier(0.16, 1, 0.3, 1),
});
return (
<span
key={i}
style={{
display: 'inline-block',
opacity: p,
filter: `blur(${(1 - p) * 12}px)`,
transform: `translateY(${(1 - p) * 18}px)`,
willChange: 'transform, filter, opacity',
}}
>
{word}
</span>
);
})}
</span>
);
};
重點字是相同的元件,但 delay 設定為 120–200ms 之後,再加上自己的顏色和 scale(1.04)。
攝影機 — 持續進行的推位
包裝整個場景。放大尺寸確保邊緣不暴露。
const Camera: React.FC<{children: React.ReactNode; durationInFrames: number}> = ({
children, durationInFrames,
}) => {
const frame = useCurrentFrame();
const scale = interpolate(frame, [0, durationInFrames], [1.0, 1.08], {
extrapolateRight: 'clamp',
easing: Easing.out(Easing.sin),
});
return (
<AbsoluteFill style={{transform: `scale(${scale})`, willChange: 'transform'}}>
{children}
</AbsoluteFill>
);
};
將攝影機放在背景層之上,任何必須固定在畫框邊緣的元素之下。
錯開的卡片堆疊
const cards = ['One', 'Two', 'Three'];
const ms = useMs();
{cards.map((label, i) => {
const local = frame - i * ms(160);
const p = interpolate(local, [0, ms(600)], [0, 1], {
extrapolateLeft: 'clamp', extrapolateRight: 'clamp',
easing: Easing.out(Easing.poly(4)),
});
return (
<div key={i} style={{
opacity: p,
transform: `translateY(${(1 - p) * 40}px)`,
}}>{label}</div>
);
})}
退場 — 進場時間的一半
const exitStart = durationInFrames - ms(300);
const out = interpolate(frame, [exitStart, durationInFrames], [1, 0], {
extrapolateLeft: 'clamp', extrapolateRight: 'clamp',
easing: Easing.in(Easing.cubic),
});
結構
每個節拍使用 <Sequence from={...} durationInFrames={...}>,直接由 motion-plan 表驅動。每個 Sequence 對應一行。節拍持續時間來自計劃,而非整數。
<Series>
<Series.Sequence durationInFrames={ms(5200)}><BeatTwo /></Series.Sequence>
<Series.Sequence durationInFrames={ms(2100)}><BeatThree /></Series.Sequence>
</Series>
確定性
- 絕不使用
Math.random()— 如果需要隨機散射,從元素索引生成種子。 - 絕不使用
Date.now()或new Date()。 - 絕不在元件內部進行 fetch。使用
staticFile()/delayRender()預加載。 - 盡可能使用
<OffthreadVideo>代替<Video>/<Audio>以保證渲染正確。
常見問題
- 同時對多個元素使用
filter: blur()很耗效能 — 限制並發的模糊節點數量,或在素材中預先模糊。 - 字體加載:使用
@remotion/google-fonts或圍繞本地FontFace.load()使用delayRender,否則前幾幀會以後備字體渲染。 - 如果輸入範圍不是單調遞增的,
interpolate會拋出錯誤 — 需要保護計算出的範圍。 - 除非你特別想要值跑出範圍,否則始終傳入
extrapolateLeft/extrapolateRight: 'clamp'。
附錄 B — HyperFrames / GSAP 配方
HyperFrames 組合 HTML + GSAP 並透過對無頭瀏覽器進行幀採樣來渲染。確定性是強制的。
執行 npx hyperframes docs 查看目前 API。本文件是其之上的動畫標準 — 關於管線(初始化 → 預覽 → 檢查 → 渲染)請參閱 hyperframes 技能。
剪輯規則(違反會導致渲染失敗)
每個有時序的元素都需要 data-start,data-duration,data-track-index 以及 class="clip"。框架擁有 .clip 的顯示與轉換控制權。
絕對不要對 .clip 元素本身使用 GSAP。 動畫一個子包裝器。
<div class="clip" data-start="4.2" data-duration="5.2" data-track-index="2">
<div class="cam"> <!-- 攝影機在此移動 -->
<div class="inner"> <!-- 元素動畫在此 -->
<h1 class="headline">…</h1>
</div>
</div>
</div>
時間軸註冊
const tl = gsap.timeline({paused: true});
window.__timelines['main'] = tl; // id 必須與 data-composition-id 匹配
始終暫停。渲染器會調用它。
緩動對照表
| 表格名稱 | GSAP |
|---|---|
| out-expo | expo.out |
| out-cubic | power2.out |
| out-quint | power4.out |
| out-back(上限) | back.out(1.2) |
| in-out-cubic | power2.inOut |
| out-sine | sine.out |
| in-cubic(退場) | power2.in |
文字 — 逐字彈出模糊淡入
在作者時間將文字拆分為單字 span(不要依賴運行時分割器 — 它可能會與第一個採樣幀競爭)。
<h1 class="headline">
<span class="w">What</span> <span class="w">looks</span>
<span class="w accent">like</span> <span class="w">discipline</span>
</h1>
tl.from('.headline .w', {
y: 18,
opacity: 0,
filter: 'blur(12px)',
duration: 0.48,
ease: 'expo.out',
stagger: 0.07,
}, 0);
// 重點字最後著陸且不同
tl.from('.headline .accent', {
scale: 0.96,
color: 'var(--surface)',
duration: 0.5,
ease: 'expo.out',
}, 0.18);
攝影機
動畫 .cam,絕不 .clip。
tl.fromTo('.cam',
{scale: 1.0},
{scale: 1.08, duration: 5.2, ease: 'sine.out', force3D: true},
0);
.cam { will-change: transform; transform: translateZ(0); }
將移動圖層放大約 6% 超過畫框,確保在推拉或漂移時邊緣永遠不會暴露。
錯開的卡片堆疊
tl.from('.card', {
y: 40, opacity: 0,
duration: 0.6, ease: 'power4.out', stagger: 0.16,
}, 1.2);
// 掃光在面板著陸後 150ms 發生
tl.fromTo('.card .sweep', {xPercent: -140}, {
xPercent: 140, duration: 0.7, ease: 'power2.inOut', stagger: 0.16,
}, 1.35);
筆觸描繪
tl.fromTo('.connector', {drawSVG: '0%'}, {drawSVG: '100%', duration: 0.8, ease: 'power2.inOut'});
// 沒有 DrawSVGPlugin?使用 stroke-dasharray/offset:
tl.fromTo('.connector', {strokeDashoffset: 1000}, {strokeDashoffset: 0, duration: 0.8, ease: 'power2.inOut'});
嚴守規則
- 僅確定性 — 沒有
Math.random(),沒有Date.now(),沒有 fetch,沒有repeat: -1。 - 9:16 = 1080×1920。 設定
#root { container-type: size; }並以cqw/cqh(1cqw = 10.8px)調整所有尺寸,絕不使用vw/vh。 - 相鄰的同軌道剪輯不可接觸。 浮點運算會使
3.2 + 0.35 = 3.5500000000000003,這會和從3.55開始的剪輯重疊,觸發overlapping_clips_same_track。留下間隙,或使用像0.34這樣的持續時間。 - 音訊: 影片為
muted;使用單個預混的主幹<audio>軌道(VO + SFX 用 ffmpegadelay+amix混合)放在高優先順位的專用data-track-index上。多個<audio>元素會在同一個無頭實例上競爭,導致定時漂移。