devto 2026-08-10 원문 보기 ↗
In this tutorial, I'll show you how to add the modern text animations shown in the cover video to your website using SplitFX , a JavaScript plugin for splitting and animating text.
You'll learn how to create a sequential hero heading and animate section titles as they enter the viewport with just a few lines of JavaScript.
🔗 Live Demo & More Examples: Explore SplitFX Demo Projects
npm install @tanglat/splitfx
Then import it into your project:
import SplitFX from "@tanglat/splitfx";
Include the CDN script below. It makes SplitFX available globally, so you can use it directly in your JavaScript:
<script src="https://cdn.jsdelivr.net/npm/@tanglat/splitfx@1/dist/umd/splitfx.min.js"></script>
We'll start by animating each section title as it enters the viewport.
const sectionTitles = document.querySelectorAll(".section .title");
Create a SplitFX instance to define how the text should animate. We'll use the same instance to animate every section title.
const textAnimator = new SplitFX({
in: {
mode: "chars",
includeSpaces: true,
animation: "fadeRight",
duration: 1000,
stagger: 40
},
out: {
mode: "words",
duration: 0,
stagger: 0
}
});
Looking for a different effect? Browse the SplitFX Demos to preview and copy ready-to-use configurations, or use SplitFX Studio to create and customize your own.
Finally, call animateOnScroll() for each title. The animation will automatically start when the element enters the viewport.
sectionTitles.forEach(title => {
textAnimator.animateOnScroll(title, { repeat: false, observerOptions: { threshold: 1 } });
});
That's it! Every section title now animates automatically the first time it enters the viewport.
We'll now recreate the animated hero heading shown at the top of the landing page. The heading cycles through multiple messages, each with its own animation.
const heroTitle = document.querySelector(".hero .title");
Create an array describing each step in the sequence. Each step defines:
const steps = [
// Step 1
{
content:
"<span style='color: #F65C1B'>Build</span> & <span style='color: #F65C1B'>Deploy</span> Smarter AI Agents in Minutes.",
allowHTML: true,
in: {
mode: "chars",
includeSpaces: false,
animation: "rotateTopRight",
duration: 500,
easing: "linear",
stagger: 50,
staggerDir: "alternate",
delay: 0
},
out: { // `out` accepts the same options as `in`, and any omitted `out` option inherits the corresponding `in` value.
delay: 3000 // Delay before "out" content stays visible for this duration after animating in and before animating out.
}
},
// Step 2
{
content:
"Turn Simple Prompts into <span style='color: #F65C1B'>Powerful</span> Automation.",
allowHTML: true,
in: {
mode: "chars",
includeSpaces: true,
animation: "fadeTop",
duration: 300,
easing: "linear",
stagger: 50,
staggerDir: "random",
delay: 0
},
out: {
delay: 3000
}
},
// Step 3
{
content:
"<span style='color: #F65C1B'>Automate</span> Your Business. <span style='color: #F65C1B'>Scale</span> Without Limits.",
allowHTML: true,
in: {
mode: "chars",
includeSpaces: true,
animation: "rotateRight",
duration: 500,
easing: "steps(2)",
stagger: 50,
staggerDir: "forward",
delay: 0
},
out: {
delay: 3000
}
}
];
Note:
outaccepts the same options asin, and any omittedoutoption inherits the correspondinginvalue.
animateSequence
Finally, call SplitFX.animateSequence() — a static method that runs a sequence of text animations inside an HTML element.
SplitFX.animateSequence(heroTitle, steps, { repeat: "infinite" });
That's it! The hero heading will now cycle through each message and repeat the sequence indefinitely.
Want to explore more animation presets, configuration options, interactive demos, and the complete documentation? Visit the SplitFX website.