split()
A lightweight, responsive and accessible text utility function to split, clone and wrap lines, words and characters of an HTML Element.
Splits are created using the text.split()
function.
import { text } from 'animejs';
const split = text.spit(target, parameters);
Parameters
Name | Accepts |
---|---|
target | A valid CSS selector String | HTMLElement |
parameters (opt) | An Object of TextSplitter settings |
Returns
TextSplitter
split() code example
import { createTimeline, stagger, utils, text } from 'animejs';
const { words, chars } = text.split('p', {
words: { wrap: 'clip' },
chars: true,
});
createTimeline({
loop: true,
defaults: { ease: 'inOut(3)', duration: 650 }
})
.add(words, {
y: [$el => +$el.dataset.line % 2 ? '100%' : '-100%', '0%'],
}, stagger(125))
.add(chars, {
y: $el => +$el.dataset.line % 2 ? '100%' : '-100%',
}, stagger(10, { from: 'random' }))
.init();
<div class="large centered grid square-grid">
<p class="text-xl">
All-in-one text splitter<br>
テキストスプリッター
</p>
</div>
#text-split .text-xl {
font-size: 1.5rem;
color: currentColor;
letter-spacing: 0.06em;
line-height: 1.35;
}
In this section