lottie
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLottie for HyperFrames
HyperFrames的Lottie集成方案
HyperFrames can seek both and dotLottie players through its runtime adapter. Lottie is a strong fit because the animation timeline is already encoded in the asset; HyperFrames only needs a player object it can seek.
lottie-weblottieHyperFrames可通过其运行时适配器来控制和dotLottie播放器。Lottie非常适合这种场景,因为动画时间轴已编码在资源中;HyperFrames只需要一个可被控制的播放器对象即可。
lottielottie-webContract
约定规则
- Load assets from local project files, usually under .
assets/ - Set .
autoplay: false - Prefer unless the user explicitly wants a loop.
loop: false - Register every returned animation or player on .
window.__hfLottie - Keep the Lottie container dimensions stable with CSS.
The adapter seeks with and dotLottie with frame or percentage APIs depending on player shape.
lottie-webgoToAndStop(timeMs, false)- 从本地项目文件加载资源,通常放在目录下。
assets/ - 设置。
autoplay: false - 除非用户明确需要循环,否则优先设置。
loop: false - 将每个返回的动画或播放器注册到上。
window.__hfLottie - 使用CSS保持Lottie容器尺寸稳定。
适配器通过控制,而dotLottie则根据播放器类型使用帧或百分比API进行控制。
goToAndStop(timeMs, false)lottie-weblottie-web Pattern
lottie-web 使用模式
html
<div id="logo-lottie" class="lottie-layer"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bodymovin/5.12.2/lottie.min.js"></script>
<script>
const anim = lottie.loadAnimation({
container: document.getElementById("logo-lottie"),
renderer: "svg",
loop: false,
autoplay: false,
path: "assets/logo-reveal.json",
});
window.__hfLottie = window.__hfLottie || [];
window.__hfLottie.push(anim);
</script>css
.lottie-layer {
width: 100%;
height: 100%;
}html
<div id="logo-lottie" class="lottie-layer"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bodymovin/5.12.2/lottie.min.js"></script>
<script>
const anim = lottie.loadAnimation({
container: document.getElementById("logo-lottie"),
renderer: "svg",
loop: false,
autoplay: false,
path: "assets/logo-reveal.json",
});
window.__hfLottie = window.__hfLottie || [];
window.__hfLottie.push(anim);
</script>css
.lottie-layer {
width: 100%;
height: 100%;
}dotLottie Pattern
dotLottie 使用模式
html
<canvas id="product-lottie" class="lottie-canvas"></canvas>
<script src="https://unpkg.com/@lottiefiles/dotlottie-web"></script>
<script>
const player = new DotLottie({
canvas: document.getElementById("product-lottie"),
src: "assets/product-flow.lottie",
autoplay: false,
loop: false,
});
window.__hfLottie = window.__hfLottie || [];
window.__hfLottie.push(player);
</script>css
.lottie-canvas {
width: 100%;
height: 100%;
display: block;
}html
<canvas id="product-lottie" class="lottie-canvas"></canvas>
<script src="https://unpkg.com/@lottiefiles/dotlottie-web"></script>
<script>
const player = new DotLottie({
canvas: document.getElementById("product-lottie"),
src: "assets/product-flow.lottie",
autoplay: false,
loop: false,
});
window.__hfLottie = window.__hfLottie || [];
window.__hfLottie.push(player);
</script>css
.lottie-canvas {
width: 100%;
height: 100%;
display: block;
}Multiple Animations
多动画场景
Push each player into the same registry:
js
window.__hfLottie = window.__hfLottie || [];
window.__hfLottie.push(backgroundAnim);
window.__hfLottie.push(iconAnim);
window.__hfLottie.push(confettiAnim);HyperFrames seeks them all to the same composition time.
将每个播放器推入同一个注册表:
js
window.__hfLottie = window.__hfLottie || [];
window.__hfLottie.push(backgroundAnim);
window.__hfLottie.push(iconAnim);
window.__hfLottie.push(confettiAnim);HyperFrames会将所有动画同步到相同的合成时间点。
Good Uses
适用场景
- After Effects exports that are already known to render correctly in lottie-web.
- Logo reveals, icon loops, decorative accents, and product UI motion.
- Translating Remotion Lottie usage into plain HyperFrames HTML.
- 已确认可在lottie-web中正确渲染的After Effects导出内容。
- Logo展示、图标循环、装饰性动效以及产品UI动画。
- 将Remotion中的Lottie用法转换为纯HyperFrames HTML代码。
Avoid
注意事项
- Relying on remote URLs at render time.
path - Starting playback with .
play() - Assuming unsupported After Effects effects will survive export. Test the JSON or file in a browser first.
.lottie - Loading a player asynchronously and registering it after HyperFrames validation has already inspected the page.
- 渲染时依赖远程URL。
path - 使用启动播放。
play() - 假设After Effects中不支持的特效在导出后仍能正常工作。请先在浏览器中测试JSON或文件。
.lottie - 异步加载播放器并在HyperFrames验证完成页面后才注册实例。
Validation
验证步骤
After editing a Lottie composition:
bash
npx hyperframes lint
npx hyperframes validate编辑Lottie合成内容后:
bash
npx hyperframes lint
npx hyperframes validateCredits And References
致谢与参考
- HyperFrames adapter source: .
packages/core/src/runtime/adapters/lottie.ts - lottie-web by Airbnb: https://github.com/airbnb/lottie-web
- lottie-web options: https://github.com/airbnb/lottie-web/wiki/loadAnimation-options
loadAnimation - dotLottie web player methods by LottieFiles: https://developers.lottiefiles.com/docs/dotlottie-player/dotlottie-web/methods
- HyperFrames适配器源码:。
packages/core/src/runtime/adapters/lottie.ts - Airbnb的lottie-web:https://github.com/airbnb/lottie-web
- lottie-web 选项:https://github.com/airbnb/lottie-web/wiki/loadAnimation-options
loadAnimation - LottieFiles的dotLottie web播放器方法:https://developers.lottiefiles.com/docs/dotlottie-player/dotlottie-web/methods