// typing animation in js:
//copy the following code:
const sleep = (milliseconds) => {
return new Promise(resolve => setTimeout(resolve, milliseconds))
}
const applyTypingAnimation = async (element, delay) => {
const stringToWrite= element.innerText;
element.innerHTML= "";
let refill= "";
const cursorHTML= "▮";
for (character of stringToWrite) {
refill+= character;
await sleep(delay)
element.innerHTML= refill+cursorHTML;
}
}
// calling the function:
applyTipingAnimation(/*your element*/, /*your delay*/)
<script src="https://unpkg.com/typewriter-effect@latest/dist/core.js"></script>
var app = document.getElementById('app');
var typewriter = new Typewriter(app, {
loop: true,
delay: 75,
});
typewriter
.pauseFor(500)
.typeString('Websites')
.pauseFor(500)
.deleteChars(9)
.pauseFor(500)
.typeString('Messenger')
.pauseFor(500)
.deleteChars(9)
.pauseFor(500)
.typeString('Instagram')
.pauseFor(500)
.deleteChars(9)
.pauseFor(500)
.typeString('Whats App')
.pauseFor(500)
.deleteChars(9)
.pauseFor(1000)
.start();