HyperFrames 动画
内置预设(data-hf-animate)
| 预设 | 描述 |
|---|
fade-in | 不透明度 0 → 1 |
fade-out | 不透明度 1 → 0 |
fade | 渐入 + 渐出 |
slide-up | 从下方平移,渐入 |
slide-down | 从上方平移,渐入 |
slide-left | 从右侧进入,渐入 |
slide-right | 从左侧进入,渐入 |
zoom-in | 缩放 0.8 → 1,渐入 |
zoom-out | 缩放 1 → 1.2,渐出 |
pop | 快速弹性缩放 |
shake | 水平抖动 |
typewriter | 逐字显示文本 |
wipe-right | 从左到右的裁剪揭示 |
wipe-left | 从右到左的裁剪揭示 |
blur-in | 模糊 20px → 0 |
blur-out | 模糊 0 → 20px |
<div data-hf-clip data-hf-animate="fade-in"
data-hf-animate-duration="0.6s"
data-hf-animate-ease="ease-out">
内容
</div>
GSAP 适配器
<script data-hf-runtime="gsap" src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/gsap.min.js"></script>
<script data-hf-timeline>
hf.at("0s", () => gsap.from("#hero h1", { y: 60, opacity: 0, duration: 0.8 }));
</script>
Lottie 适配器
<div data-hf-clip data-hf-start="1s" data-hf-duration="auto"
data-hf-lottie="assets/confetti.json"
data-hf-lottie-loop="false">
</div>
Three.js 适配器
<canvas id="scene3d" data-hf-clip data-hf-runtime="threejs" data-hf-start="0s" data-hf-duration="6s"></canvas>
<script data-hf-runtime="threejs" data-hf-target="#scene3d">
const scene = new THREE.Scene();
hf.onFrame((t) => { mesh.rotation.y = t * 0.5; });
</script>
Anime.js 适配器
<script data-hf-runtime="animejs"></script>
<script data-hf-timeline>
hf.at("0.5s", () => anime({ targets: "#logo", scale: [0, 1], duration: 600, easing: "spring(1,80,10,0)" }));
</script>
WAAPI 适配器
<script data-hf-timeline>
hf.at("1s", () => {
document.querySelector("#badge").animate(
[{ opacity: 0, transform: "scale(0.5)" }, { opacity: 1, transform: "scale(1)" }],
{ duration: 500, fill: "forwards" }
);
});
</script>
TypeGPU 适配器
<canvas id="gpu-canvas" data-hf-clip data-hf-runtime="typegpu" data-hf-start="0s" data-hf-duration="8s"></canvas>
<script data-hf-runtime="typegpu" data-hf-target="#gpu-canvas">
hf.onFrame((t) => { });
</script>
hf 时间线 API
| 方法 | 描述 |
|---|
hf.at(time, fn) | 在绝对场景时间运行 fn |
hf.onFrame(fn) | 每帧运行;fn 接收秒数 |
hf.clock | 当前渲染时间(秒) |
hf.scene | 当前场景 ID |
hf.fps | 配置的帧率 |