text animation fancy text js part

 const text = document.querySelector(".fancy");

const strText = text.textContent;
const spiltText = strText.split("");
Text.textContent = "";
for (let i = 0i<spiltText.lengthi++){
    Text.innerHtml + ="<span>" +spiltText [i] + "</span>";

}
let char = 0;
let timer = setInterval(onTick,50);
function onTick(){
    const span = text.querySelectorAll('span')[char];
    span.classList.add('.fade');
    char++;
    if (char === spiltText.length){
        complete();
        return;
    }
}
function complete(){
    clearInterval(timer);
    timer = null;
}

Comments