1.0.4 โ€ข Published 1 year ago

@tasul/shuffle-text v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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

shshsh

// 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

OptionTypeDefaultDescription
textArrayarray[]Array of words or sentences to shuffle.
isAutobooleanfalseDefine whether to play automatically(true) or not(false). (After the page load)
isReplacedRandomlybooleanfalseDefine whether to switch alphabets randomly(true) or in order(false).
isDisorderedArraybooleanfalseDefine whether to mix(true) โ€˜textArrayโ€™ or use it in order(false).
stayTimeint1500Time to stay after shuffling
replaceTimeint50Time to switch alphabets

๐Ÿ“Œ Methods

MethodDescription
clearDestroy ShuffleText
playShuffle text once
playAutoStart shuffling automatically (Add to any event you want)
1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago