Helpers API
These helpers are built to make common split-text animation patterns easier to implement. This is a growing collection, and more utilities will be added over time.
createSplitClones()
Creates clone layers (and optional track wrappers) from split output. This is useful for reveal/swap effects without coupling to a specific animation library.
Parameters
SplitTextResult
SplitTextResult from splitText().
CreateSplitClonesOptions
Context callbacks receive:
{
index: number;
unit: "chars" | "words" | "lines";
original: HTMLSpanElement;
}Return Value
Behavior Notes
- The helper does not call
splitText(); pass an existing split result. - Clones are appended to each original node's current parent.
- With
wrap: false, clone is appended directly to the existing parent. - With
wrap: true, each original is moved into a generated track wrapper first, then the clone is appended there. cleanup()is idempotent and removes helper-created DOM.cleanup({ revertSplit: true })also callssplit.revert().
For reveal/swap effects, pair this with matching mask in splitText() ("chars", "words", or "lines").