Randext Randext Randext Randext Randext Randext Randext

A programable, random letter animation effect to display text messages


// Randext ES Module and UMD Module available
import Randext from 'randext';
const randext = new Randext({
      element: document.querySelect("[data-randext]"),
      ignore: '-_,;:./()[]{}<>\'"`#$%&@€!?',
      interval: 50,
      callback: null,
});
randext.start();

      

A Highly Flexible, Performant, Accessible & Customizeable JavaScript Library.

NPM

installation
npm install randext --save

GIT

ZIP
https://github.com/exiguus/js.randext/archive/v1.0.0.zip
GZIP
https://github.com/exiguus/js.randext/archive/v1.0.0.tar.gz

Usage

ES Module



import Randext from 'randext';

const randext = new Randext({
  element: document.querySelect('[data-randext]'),
  interval: 60,
  ignore: '-_,;:./()[]{}<>\'"`#$%&@€!?',
  style: ['small', 'underlined', 'strong'],
  callback: () => {},
});

randext.start();


UMD Module


<script type="text/javascript" src="node_modules/js.randext/dist/randext.min.js"></script>
<script type="text/javascript">
  var randrext = new window.Randext.default({
    element: document.querySelect('[data-randext]'),
    interval: 60,
    ignore: '-_,;:./()[]{}<>\'"`#$%&@€!?',
    style: ['small', 'underlined', 'strong'],
    callback: () => {},
  });

  randext.start();
</script>

CSS




[data-randext] {
  display: block;
  margin-bottom: 1em;
  unicode-bidi: embed;
  font-family: inherit;
  font-size: 1em;
  letter-spacing: .064em;
  line-height: 1.875em;
  white-space: pre-line;
  width: 100%;
  color: inherit;
}




[data-randext] {
  opacity: 0;
}

[data-randext="true"] {
  opacity: 1;
}

[data-randext-char] {
  display: inline-block;
  width: .65em;
  height: 1.66em;
  font-size: inherit;
  font-family: inherit;
  letter-spacing: inherit;
  line-height: 1.6em;
  vertical-align: middle;
}

[data-randext-char-active="true"] {
  font-weight: bold;
  opacity: 1;
}


ES Module Callback — Generator, yield, next()



import Randext from 'randext';

const elements = document.querySelectorAll('[data-randext]');

function* init(configs) {
  for (let i = 0; i < configs.length; i++) {
    yield emit(configs[i]);
  }
}

function emit(config) {
  config.instance.start();
}

const configs = [];

elements.forEach( (element) => {
  configs.push({
    instance: null,
    settings: {
      element: element,
      callback: () => text.next(),
    },
  });
});

configs.forEach( (config) => {
  config.instance = new Randext(config.settings);
  config.instance.init();
});

const text = init(configs);
text.next();