Customizable text effects
npm install txt-fx
Customizable text effects!
To install for your project run:
``sh`
npm i txt-fx
js
import TextFX from 'txt-fx'
`Then create an instance of the effect you want and give it the target element.
`js
const fx = new TextFX.Scrambler();
const element = document.querySelector('#headline');
fx.scramble(element);
`$3
- Scrambler
- Shuffler
- Replacer$3
Scrambler.scrambleScrambles the text with random characters in random order.
`js
const { scramble } = new TextFX.Scrambler();
scramble(element, delay, count, restore);
`| Parameter | Type | Default value | Description |
| --- | --- | --- | --- |
| element | element | - | target element |
| delay | number | 400 | delay between changes |
| count | number | infinity | number of iterations |
| restore | boolean | false | restore text at end of count |
| items | string[] | [ '@', '#', '$', ...] | random characters to use |
$3
Shuffler.shuffleshuffles the text's order in place.
`js
const { shuffle } = new TextFX.Shuffler();
shuffle(element, delay, count, restore);
`| Parameter | Type | Default value | Description |
| --- | --- | --- | --- |
| element | element | - | target element |
| delay | number | 400 | delay between changes |
| count | number | infinity | number of iterations |
| restore | boolean | false | restore text at end of count |
$3
Replaces each char sequentially with a given char or a char from a list of chars.
`js
const { replace } = new TextFX.Replacer();
replace(element, delay, restore, char);
`| Parameter | Type | Default value | Description |
| --- | --- | --- | --- |
| element | element | - | target element |
| delay | number | 400 | delay between changes |
| restore | boolean | false | restore text at end of count |
| char | string \|\| string[] | █ | replacement chars |
$3
`sh
npm test
`
Contributing
1. Fork it!
2. Create your feature branch:
git checkout -b my-new-feature
3. Add your changes: git add .
4. Commit your changes: git commit -am 'Add some feature'
5. Push to the branch: git push origin my-new-feature`MIT License © Hamid Yuksel