type-machine
v0.0.3
Published
make typing effect by React
Downloads
15
Readme
TypeMachine 是一个 React 组件,通过简单的配置就能实现打字效果。

Usage
npm install type-machineimport React form 'react'
import TypeMachine from 'type-machine'
class Demo extends React.Component {
render () {
const texts = [
[{ string: '第一行', color: 'red' }],
[{ string: '第二行' }, { string: '同行换色', color: 'yellow' }]
]
return (
<TypeMachine texts={texts} speed={500} defaultColor='#BBB' />
)
}
}
export default Demo

API
| 参数 | 类型 | | --- | --- | | texts | Array | | speed | Number | | defaultColor | String |
texts
texts = [
[{string: ‘第一行’}],
[{string: ‘第二行’}, {string: '同行变色’, color: ‘red’}],
[string: ‘换行变色’, color: ‘yellow']
]speed
两个字符间隔时间(ms)defaultColor
rgb(a, b, c) || #FFF || black