API

Methods

Initialize new instance

You can initialize TypesetBot with or without a variable.

new TypesetBot('.container');
// or
var tsb = new TypesetBot('.container');

unwatch and watch

TypesetBot will by default watch if the viewport changes and rerun everytime. By calling unwatch() the TypesetBot instance will stop rerunning on viewport changes. Calling watch() will have the TypesetBot instance watch for viewport changes again.
// Unwatch for viewport changes.
tsb.unwatch();
// Watch for viewport changes again.
tsb.watch()

rerun

If you need to force a rerun of the typesetting algorithm call rerun() and the TypesetBot instance will rerun.
// Rerun instance.
tsb.rerun();

terminate

If you want to stop using TypesetBot you can call terminate() and content will revert to the original content and memory will be cleared up.
// Terminate instance.
tsb.terminate();

Events

typesetbot-viewport--reize

A single piece of code checks for viewport changes and dispatches an event to trigger all watching instances to rerun. Fire an event if all watching TypesetBot instances should rerun.
// Rerun all watching instances.
document.body.dispatchEvent(new Event('typesetbot-viewport--reize'));