Typing text animation
This guide will show you how to create an eye-catching typing text animation for your headlines in just a few steps.
Copy this code:
Paste it into your General settings > </body> custom HTML code
In the following code, replace the words that will be animated with your own ones:
This is what you need to replace (make sure to keep the quotes!):
You can add or remove any number of words. For example, this is the code with only 2 words:
And this is the same code with 5 words:
This step may seem a little tricky, but it's much easier than it looks 😉
Copy the code from step 3 and paste it inside the required headline field (at the very end):
Write text that will be placed before the animated part:
Save changed and open the live version of your website to see the results 🔥
If the width of your headline is too big, you might see constant shifts:
To fix that, simply move the animated part to the new line by adding tag <br> next to its code:
You also might want to change the color of the cursor.
To do so, go to the code that you added to your General settings > </body> custom HTML code and replace the color code here:
Step 1/5
Copy this code:
<script>
var TxtRotate = function(el, toRotate, period) {
this.toRotate = toRotate;
this.el = el;
this.loopNum = 0;
this.period = parseInt(period, 10) || 2000;
this.txt = '';
this.tick();
this.isDeleting = false;
};
TxtRotate.prototype.tick = function() {
var i = this.loopNum % this.toRotate.length;
var fullTxt = this.toRotate[i];
if (this.isDeleting) {
this.txt = fullTxt.substring(0, this.txt.length - 1);
} else {
this.txt = fullTxt.substring(0, this.txt.length + 1);
}
this.el.innerHTML = '<span class="wrap">'+this.txt+'</span>';
var that = this;
var delta = 300 - Math.random() * 100;
if (this.isDeleting) { delta /= 2; }
if (!this.isDeleting && this.txt === fullTxt) {
delta = this.period;
this.isDeleting = true;
} else if (this.isDeleting && this.txt === '') {
this.isDeleting = false;
this.loopNum++;
delta = 500;
}
setTimeout(function() {
that.tick();
}, delta);
};
window.onload = function() {
var elements = document.getElementsByClassName('txt-rotate');
for (var i=0; i<elements.length; i++) {
var toRotate = elements[i].getAttribute('data-rotate');
var period = elements[i].getAttribute('data-period');
if (toRotate) {
new TxtRotate(elements[i], JSON.parse(toRotate), period);
}
}
var css = document.createElement("style");
css.type = "text/css";
css.innerHTML = ".txt-rotate > .wrap { border-right: 0.08em solid #303030 } .txt-rotate, .wrap { font-family: inherit !important;}";
document.body.appendChild(css);
};
</script>
Step 2/5
Paste it into your General settings > </body> custom HTML code
Step 3/5
In the following code, replace the words that will be animated with your own ones:
<span class="txt-rotate" data-period="2000" data-rotate='[ "Makers", "Founders", "Hackers" ]'></span>
This is what you need to replace (make sure to keep the quotes!):
You can add or remove any number of words. For example, this is the code with only 2 words:
<span class="txt-rotate" data-period="2000" data-rotate='[ "Makers", "Founders" ]'></span>
And this is the same code with 5 words:
<span class="txt-rotate" data-period="2000" data-rotate='[ "Makers", "Founders", "Hackers", "Coders", "Marketers" ]'></span>
This step may seem a little tricky, but it's much easier than it looks 😉
Step 4/5
Copy the code from step 3 and paste it inside the required headline field (at the very end):
Step 5/5
Write text that will be placed before the animated part:
Done!
Save changed and open the live version of your website to see the results 🔥
Additional adjustments
If the width of your headline is too big, you might see constant shifts:
To fix that, simply move the animated part to the new line by adding tag <br> next to its code:
You also might want to change the color of the cursor.
To do so, go to the code that you added to your General settings > </body> custom HTML code and replace the color code here:
Updated on: 18/12/2023
Thank you!