@huasi/text-shuffle
Version:
## Install
131 lines (86 loc) • 2.52 kB
Markdown
```bash
yarn add txt-shuffle
pnpm i @huasi/text-shuffle
npm i @huasi/text-shuffle
```
```js
import shuffle from '@huasi/text-shuffle';
shuffle({
text: 'Hello world! from Huasi.dev',
onUpdate: shuffleStr => {
console.log(shuffleStr);
},
onComplete: () => {
console.log('Shuffle complete!');
},
});
```
Text to shuffle.
| Type | Required | Default |
| ------ | -------- | ------- |
| string | true | '' |
Animation duration in seconds.
| Type | Required | Default |
| ------ | -------- | ------- |
| number | false | 1 |
Time to spend before starting the animation.
| Type | Required | Default |
| ------ | -------- | ------- |
| number | false | 0 |
Time to spend to resolving the animation.
| Type | Required | Default |
| ------ | -------- | ------- |
| number | false | 0.2 |
Frames per second.
| Type | Required | Default |
| ------ | -------- | ------- |
| number | false | 60 |
String of characters to use in the shuffle animation
| Type | Required |
| ------ | -------- |
| string | false |
Default: `' !#$&%()*+0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuüvwxyz{|}~'`
Animation type, possible values: `show`, `hide`, `stay`
| Type | Required | Default |
| ------ | -------- | ------- |
| string | false | 'show' |
Direction of the animation, possible values: `left`, `right`, `random`
| Type | Required | Default |
| ------ | -------- | ------- |
| string | false | 'left' |
Callback function to be called on each frame of the animation.
```js
onUpdate = string => {
console.log(string);
};
```
Callback function to be called when the animation is complete.
```js
onComplete = string => {
console.log('Shuffle complete!', string);
};
```
MIT, see [LICENSE](LICENSE) for details.
- [eases](https://github.com/mattdesl/eases) - [License](https://github.com/mattdesl/eases/blob/master/LICENSE.md)
- [canvas-sketch-util](https://github.com/mattdesl/canvas-sketch-util) - [License](https://github.com/mattdesl/canvas-sketch-util/blob/master/LICENSE.md)
- [txt-shuffle](https://github.com/brunoimbrizi/txt-shuffle) - [License](https://github.com/brunoimbrizi/txt-shuffle/blob/main/LICENSE)