Skip to content

TextSwap

The TextSwap text effect compares string differences, wraps character positions inside vertical overflow-hidden layouts, and translates mismatched characters vertically to exit old letters and slide in new ones.


Basic Character Swap

The text configuration parameter defines the target string. Mismatched letters slide out while matching characters remain stable.

SWAP MOTION

60 FPS

Snappy Fast Transition

Reducing duration and stagger properties creates a rapid, high-speed character swap sequence.

SLIDING

60 FPS

Elastic Overshoot Easing

Applying a back ease curve (e.g. 'back.out(N)') introduces a bouncy settling effect as incoming characters lock into position.

SPRING TRANSITION

60 FPS

Revert Layout on Completion

Setting revertOnComplete: true collapses all temporary inline positioning <span> containers and restores clean string content to the target DOM element upon transition completion.

ORIGINAL STATE

60 FPS

Interactive Cycle Sequencer

Because TextSwap processes string differences, multiple calls can be sequenced to cycle between a list of strings on click.

DEVELOPMENT

60 FPS

API Reference

javascript
import { textSwap } from 'animx/plugins/Text'

const tl = textSwap(target, config)

Configuration Options

OptionDefaultDescription
textRequiredThe target text content string to transition into.
duration0.6Transition duration of each individual character in seconds.
stagger0.04Delay offset between subsequent character launches in seconds.
ease'cubic.inOut'Deceleration easing profile applied to vertical translations.
revertOnCompletefalseRestores original text layout structures upon timeline completion.
pausedfalseStandard playback initialization lock flag.