Hey there! I'm currently experimenting with different animations using anime js. My latest goal is to achieve a Typewriter Effect for text using anime.js, similar to this awesome live demo here.
Here's what I've got so far.
HTML:
<div class="text-animation">
Welcome to codingflag
</div>
CSS:
body {
margin:0px;
height:100vh;
display:flex;
align-items:center;
justify-content:center;
background:#222;
}
.text-animation {
color:#f5f5f5;
font-size:50px;
font-family:"Passion One",sans-serif;
letter-spacing:1px;
}
.text-animation .letter {
display:inline-block;
}
JavaScript:
var element = document.getElementsByClassName("text-animation")[0];
element.innerHTML = element.textContent.replace(/\S/g,'<span class="letter">$&</span>');
anime.timeline({loop:true})
.add({
targets:'.text-animation .letter',
scale:[3,1],
opacity:[0,1],
translateZ:0,
duration:1000,
easing:"easeOutExpo",
delay:(elem, index) => index*70
})
.add({
targets:'.text-animation',
opacity:0,
duration:1000,
delay:1000,
easing:"easeOutExpo"
})
Check out my CODEPEN example: type writer effect.
What else should I include to achieve the desired result like the one in the provided sample?