1.0.4 โข Published 1 year ago
@tasul/shuffle-text v1.0.4
ShuffleText
'ShuffleText' is a JavaScript library for text switching effects.
You can switch any words or sentences you want to show randomly or in order.
๐ Install
npm i @tasul/shuffle-text
๐ Basic Usage
// html
<div class="my-target"></div>
// js
// const myShuffle = new ShuffleText(target, options)
const shuffleText = new ShuffleText(".my-target", {
textArray: [ "Hello", "Yo!", "ยกHola!", "Salut", "Ciao", "์๋
ํ์ธ์", "ใใใซใกใฏ" ],
isAuto: false,
isReplacedRandomly: false,
isDisorderedArray: false,
stayTime: 1500,
replaceTime: 50,
})
Cases
// case 1
const shuffleText1 = new ShuffleText(".my-target-1", {
textArray: [ "Hello", "Yo!", "ยกHola!", "Salut", "Ciao", "์๋
ํ์ธ์", "ใใใซใกใฏ" ],
isAuto: true,
})
// case 2
const shuffleText2 = new ShuffleText(".my-target-2", {
textArray: [ "Hello", "Yo!", "ยกHola!", "Salut", "Ciao", "์๋
ํ์ธ์", "ใใใซใกใฏ" ],
isAuto: true,
isReplacedRandomly: true,
})
// case 3
const shuffleText3 = new ShuffleText(".my-target-3", {
textArray: [ "Hello", "Yo!", "ยกHola!", "Salut", "Ciao", "์๋
ํ์ธ์", "ใใใซใกใฏ" ],
isAuto: true,
isDisorderedArray: true,
})
// case 4
const shuffleText4 = new ShuffleText(".my-target-4", {
textArray: [ "Hello", "Yo!", "ยกHola!", "Salut", "Ciao", "์๋
ํ์ธ์", "ใใใซใกใฏ" ],
isAuto: true,
isReplacedRandomly: true,
isDisorderedArray: true,
})
๐ Parameter
target
The element that you want to use 'shuffle text'.
Use the โidโ or โclassโ name of the element.
options
Option | Type | Default | Description |
---|---|---|---|
textArray | array | [] | Array of words or sentences to shuffle. |
isAuto | boolean | false | Define whether to play automatically(true) or not(false). (After the page load) |
isReplacedRandomly | boolean | false | Define whether to switch alphabets randomly(true) or in order(false). |
isDisorderedArray | boolean | false | Define whether to mix(true) โtextArrayโ or use it in order(false). |
stayTime | int | 1500 | Time to stay after shuffling |
replaceTime | int | 50 | Time to switch alphabets |
๐ Methods
Method | Description |
---|---|
clear | Destroy ShuffleText |
play | Shuffle text once |
playAuto | Start shuffling automatically (Add to any event you want) |