@zachacious/textsplitter
v1.0.1
Published
Splits text into individual elements for words and characters for the purpose of animation with the ability to revert back regular text
Downloads
4
Maintainers
Readme
TextSplitter
Split an element with text into multiple elements containing words and chars. Small < 2kb
Installation
npm install @zachacious/textsplitter
Usage
import { TextSplitter } from "textsplitter";
/*All possible options*/
const options = {
type: "word, char", // create word elements that contain character elements
element: "div", // the new elements created will be divs
};
const myTextEls = TextSplitter.split("#text-el", options);
/* ...do some animation or something... */
/* myTextEls.words -> array of word elements */
/* myTextEls.chars -> array of char elements */
/* restore the original text element */
myTextEls.revert();