JSFiddle - React, Tailwind, and code Playground

by luka kupunia

HTML

<div class="circle">
    <div class="circle-1"></div>
    <div class="circle-2"></div>
    <div id="demo" data-text="Discover..."></div>
</div>

CSS

body {
    background: lightblue;
}
div.circle {
    width: 200px;
    height: 200px;
    margin: 200px;
    /* border: 1px dashed black; */
    position: relative;
}
div.circle div#demo {
    position: absolute;
    top:50%;
    left:50%;
    transform: translate(-50%,-50%);
    font-size: 22px;
}
div.circle div.circle-1 {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 50%;
    background: white;
    opacity: .3;
    animation: a cubic-bezier(0.03, 0, 0, 0.99) .5s  forwards;
    transform: scale(0);
}
div.circle div.circle-2 {
    top: 13.5px;
    left: 13.5px;
    right: 13.5px;
    bottom: 13.5px;
    position: absolute;
    background: white;
    border-radius: 50%;
    transform: scale(0);
    animation: a cubic-bezier(0.03, 0, 0, 0.99) .5s .1s forwards;
}
@keyframes a {
    from { transform: scale(0) }
    to { transform: scale(1) }
}

JavaScript

var a = document.querySelector('#demo')
var kfn_type = function(element,speed){
        var text = element.dataset.text;
        var arr = Array.from(text);
        var b = 0;
        element.innerHTML = '';
        var int = setInterval(function(){
            if (b === arr.length - 1) {
                clearInterval(int)
            }
            element.innerHTML += arr[b];
            b++;
        },speed)    
    }
setTimeout(function(){
	kfn_type(a,40)
},500)
/*     
    setTimeout(function(){
        
    var arr = Array.from(a.innerHTML);
    var b = arr.length;
    setInterval(function(){
        a.innerHTML += arr[b];
    },1000)
    
    },2000) */