Splits text into individual elements for words and characters for the purpose of animation with the ability to revert back regular text
npm install @zachacious/textsplitterSplit an element with text into multiple elements containing words and chars.
Small < 2kb
``bash`
npm install @zachacious/textsplitter
`javascript
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();
``