1.0.6 • Published 2 years ago

@huasi/text-shuffle v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@huasi/text-shuffle

Install

# with yarn
yarn add txt-shuffle

# with pnpm
pnpm i @huasi/text-shuffle

# with npm
npm i @huasi/text-shuffle

Usage

import shuffle from '@huasi/text-shuffle';

shuffle({
  text: 'Hello world! from Huasi.dev',
  onUpdate: shuffleStr => {
    console.log(shuffleStr);
  },
  onComplete: () => {
    console.log('Shuffle complete!');
  },
});

Props

text

Text to shuffle.

TypeRequiredDefault
stringtrue''

duration = DEFAULT_DURATION,

Animation duration in seconds.

TypeRequiredDefault
numberfalse1

delay

Time to spend before starting the animation.

TypeRequiredDefault
numberfalse0

delayResolve

Time to spend to resolving the animation.

TypeRequiredDefault
numberfalse0.2

fps

Frames per second.

TypeRequiredDefault
numberfalse60

glyphs

String of characters to use in the shuffle animation

TypeRequired
stringfalse

Default: ' !#$&%()*+0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuüvwxyz{|}~'

animation

Animation type, possible values: show, hide, stay

TypeRequiredDefault
stringfalse'show'

direction

Direction of the animation, possible values: left, right, random

TypeRequiredDefault
stringfalse'left'

Methods

onUpdate = null,

Callback function to be called on each frame of the animation.

onUpdate = string => {
  console.log(string);
};

onComplete

Callback function to be called when the animation is complete.

onComplete = string => {
  console.log('Shuffle complete!', string);
};

License

MIT, see LICENSE for details.

References

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago