Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/howel52/TypeMachine

React 模拟打字组件
https://github.com/howel52/TypeMachine

Last synced: about 2 months ago
JSON representation

React 模拟打字组件

Awesome Lists containing this project

README

        

TypeMachine 是一个 React 组件,通过简单的配置就能实现打字效果。

![](http://ww3.sinaimg.cn/large/0060lm7Tly1fnoiuwgj0mg30930fv3zt.gif)

# Usage
```
npm install type-machine
```

```
import React form 'react'
import TypeMachine from 'type-machine'

class Demo extends React.Component {
render () {
const texts = [
[{ string: '第一行', color: 'red' }],
[{ string: '第二行' }, { string: '同行换色', color: 'yellow' }]
]
return (

)
}
}
export default Demo

```
![](http://ww4.sinaimg.cn/large/0060lm7Tly1fnojvzvw5zg309303hq2q.gif
)

# 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
```