⚡️ 本库是基于 typed.js 的 fork,专为极致字符输出速度和批量输出优化。
- 一次输出多个字符:通过
newCharPerStep
参数控制每次输出的字符数,极大提升速度上限。 - typeSpeed=0 真正极速:当
typeSpeed
设为 0 时,字符几乎瞬间输出。 - 完全兼容 typed.js 的全部用法和参数。
npm install fast-typed
import FastTyped from 'fast-typed';
const typed = new FastTyped('#element', {
strings: ['<i>First</i> sentence.', '& a second sentence.'],
typeSpeed: 0,
newCharPerStep: 10,
});
newCharPerStep
:每次输出的字符数,默认 1。数值越大,速度越快。
strings
:要输出的字符串数组typeSpeed
:每个字符输出间隔(毫秒),0 为最快backSpeed
:回退速度startDelay
:开始前延迟backDelay
:回退前延迟loop
:是否循环showCursor
:是否显示光标- ...(其余参数同 typed.js)
var typed = new FastTyped('#element', {
strings: ['极速输出', '一次输出多个字符!'],
typeSpeed: 0,
newCharPerStep: 8,
loop: true,
});
- 支持 HTML 字符串、回退、暂停、回调等全部 typed.js 能力。
- 详细参数与事件请参考 typed.js 文档。
MIT
本库 fork 自 mattboldt/typed.js,并在其基础上做了速度和批量输出增强。