character-shuffling

v1.0.0
Shuffle the text content of DOM elements, whether to its original charater data or to new specific string values.
shuffle shuffling character letters words animation text DOM random and 2 more...

character-shuffling

npm-image

Install

NPM

npm install character-shuffling --save

Basic Usage

var CS = require('character-shuffling');

var element = document.getElementById('sample-text');
var text = new CS(element, /* options */);

// shuffle its current character data
text.shuffle();

// shuffle to a new string specified by the `text` option
text.shuffle({text : 'Some new text to animate...'});

Default Options

You can extend this options during instantiation (second param) or when calling the shuffle method.

{
    /* The characters to use when selecting characters randomly. 
     * [String]
     */
    chars : "abcdefghijklmnopqrstuvwxyz" +
            "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
            "0123456789" +
            ",.?/\\(^)![]{}*&^%$#'\"",
            
    /* How many times should the letters be changed. 
     * [Number]
     */
    times : 10,
    
    /* String to shuffle to 
     * [String]
     */
    text : this.element.textContent,
    
    /* Function to be call once the shuffling is complete. 
     * [Function]
     */
    callback : null
}

License

MIT © Noel Delgado

npm i character-shuffling

Metadata

  • MIT
  • Whatever
  • Noel Delgado
  • released 9/12/2015

Downloads

Maintainers