Word Swap in a Sentence
A sentence stays put while one word rolls vertically like a slot machine into the next, the slot width easing along; for naming three audiences or use cases in one line.
Motion5s1920×1080 · 30fpsLaunchFeatureBrand
0s / 5sFrame 0
Copy it exactly
用 `/hyperframes` 做一条 1920×1080、30 fps、5 秒的动效:一句话固定不动,中间一个词像老虎机一样纵向滚动,依次换成三个词。
1. 画面:底色 `#E8E6E1`;整句一行,单字号 200px(上限;英文等更长的句子按整句最宽状态缩小:字号 = min(200, floor(1560 / 最宽状态在 100px 下的宽度 × 100)),1560px 是画面宽度的 81%)、字重 600、字距 -0.01em、行高 1.3;固定文字 `#1C1C1A`,被换的词 `#2F5BFF`,全片只有它带颜色。中文用 Noto Sans SC,西文用 IBM Plex Sans,本地 `@font-face`。没有线、边框、底色块、其他装饰。
2. 文案:「为 设计师 / 工程师 / 产品经理 而做」。英文:Built for designers / engineers / founders,后缀留空。
3. 版式:句子左端对齐,一行,垂直居中(词槽中线 y=540px);左端 x 按最宽状态(产品经理,整句 1480px)算成左右居中,中文下是 220px。词与词之间空 0.2em(40px)。「为」从头到尾位置不变。
4. 词槽:(时间线里词带 y、模糊、词槽宽度的每个 fromTo 都要加 `immediateRender: false`,并先 `gsap.set` 到第一个词,否则第二次换词的起始值会盖掉第一次,开头会错停在工程师)一个 `overflow: hidden` 的窗口,高 260px(= 1.3 × 200),宽等于当前词的宽度;窗口里竖着排三个词,每个词占 260px 高。换词 = 整条词带上移 260px,旧词从上沿滚出,新词从下沿滚进。词槽没有边框、没有底色。
5. 节拍:0 – 1.1 秒停留在设计师;1.1 – 1.5 秒换成工程师;1.5 – 2.6 秒停留;2.6 – 3.0 秒换成产品经理;3.0 – 5.0 秒停留到结束。每次换词 0.4 秒,缓动 `power3.inOut`。每个词停留不少于 1.1 秒。
6. 宽度过渡:每次换词时,词槽宽度和滚动同起点、同时长、同缓动,从旧词宽度变到新词宽度(设计师 600px,工程师 600px,产品经理 800px),右边的「而做」跟着槽的右沿平滑移动,句子不跳。宽度要在代码里用字体加载完成后的实际字宽算出来,不要写死。
7. 拖影:不要依赖渲染器的 `data-motion-blur`(子合成里不生效)。在换词的时间线里给词带加 CSS 模糊:换词前 0.2 秒 `blur(0px)` 到 `blur(9px)`(`power2.out`),后 0.2 秒回到 `blur(0px)`(`power2.in`);停留时完全清晰。
8. 禁止:整句一起动、换词时闪白或淡入淡出、词槽边框或底色块、下划线、弹跳、呼吸漂浮、小标签。
需要替换的地方(在 `index.html` 里 `id="swap"` 的挂载元素上写 `data-variable-values='{"pre":"Built for","post":"","word1":"designers","word2":"engineers","word3":"founders"}'` 传入;换别的中文词后要重新生成字体子集,否则缺字):
- 文案:`pre`(前缀)、`word1`、`word2`、`word3`(三个被换的词)、`post`(后缀,可为空)。字号会按整句最宽状态缩小,保证整句不超过画面宽度的 81%。
- 颜色:`accentColor`、`ink`、`bg`。
- 时间和缓动:`swapOneAt`(1.1)、`swapTwoAt`(2.6)、`swapDuration`(0.4,范围 0.35–0.45)、`swapEase`(power3.inOut)。
- 不要加产品界面和其他文字。Learn the technique
固定的句子里留一个 260px 高的无边框窗口,窗口里竖排三个词,整条词带每次上移一个行高,0.4 秒 `power3.inOut`,同时用同样的时间和缓动把窗口宽度从旧词宽度过渡到新词宽度,让后面的字平滑跟过去;每个词停留 1.1 秒以上,只有被换的词带强调色。
MCP
get_video({ "id": "motion-text-word-swap" })Beats
| Time | Purpose | Visual | Camera | Transition | On-screen text |
|---|---|---|---|---|---|
| 0–1.1s | Let the viewer read the sentence and the first word | Sentence still, the slot shows the first word in the accent color, the rest in ink | static | — | Built for designers |
| 1.1–1.5s | First swap | The word strip rolls up 260 px, power3.inOut, 0.4 s; both words are the same width so nothing else moves | static | — | Built for engineers |
| 1.5–2.6s | Read the second word | Fully still | static | — | — |
| 2.6–3s | Second swap, the slot widens | Same 0.4 s roll; slot width 600 to 800 px on the same ease, the trailing text glides 200 px right, the leading text never moves | static | — | Built for founders |
| 3–5s | Final hold | Fully still to the end, 2 s | static | — | — |
Parameters
| Parameter | Default | Range | Kind |
|---|---|---|---|
Leading text pre | 为 | — | Content |
First word word1 | 设计师 | — | Content |
Second word word2 | 工程师 | — | Content |
Third word word3 | 产品经理 | — | Content |
Trailing text post | 而做 | — | Content |
Accent color accentColor | #2F5BFF | — | Look |
Text color ink | #1C1C1A | — | Look |
Background bg | #E8E6E1 | — | Look |
Max font size fontSize | 200px | 120 – 240px | Look |
First swap start swapOneAt | 1.1s | 0.5 – 2s | Timing |
Second swap start swapTwoAt | 2.6s | 1.9 – 3.4s | Timing |
Swap duration swapDuration | 0.4s | 0.35 – 0.45s | Motion |
Swap ease swapEase | power3.inOut | — | Motion |
Good for
- One sentence that names 3 parallel audiences or use cases
- The claim line of a launch film, hero or product intro
- Words of 3 to 4 Chinese characters or one short English word
Not for
- Swapping the whole sentence at once
- Long words or lists of more than 3
- Each option needing its own picture