scrambleText 新
通过逐字乱码和显示效果为文本设置动画。
scrambleText() 返回一个基于函数的补间值,通过乱码动画逐步显示目标的文本内容。它直接用作 animate() 中的属性值。
import { scrambleText } from 'animejs';
animate(target, { innerHTML: scrambleText(parameters) });
或者作为独立模块从 'animejs/text' 子路径 导入
import { scrambleText } from 'animejs/text';
参数
| 名称 | 接受 |
|---|---|
| 参数 (可选) | 一个包含 scrambleText 参数 的 Object(对象) |
返回
一个与 animate() 兼容的基于函数的补间值。
推荐使用 innerHTML 而非 textContent,因为 scrambleText 在内部使用 来保留空格,这需要进行 HTML 解析。
scrambleText 代码示例
import { animate, scrambleText } from 'animejs';
animate('p', {
innerHTML: scrambleText(),
loop: true,
loopDelay: 1000,
});
<div class="large row">
<p class="text-s text-mono">scrambleText() allows you to reveal a text via a smooth randomized character scramble transition effect.</p>
</div>
本节内容