UNPKG

fresh-typedjs

Version:

My library lets you input text (a word or a paragraph) and specify a timing to animate writing or deleting each letter one by one,

1 lines 1.25 kB
!function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict";const e=["parsa","fresh","typed","javaScript"],t=1500;document.querySelectorAll(".freshType").forEach(e=>{e.classList.add("relative"),e.classList.add("afterText"),e.style.whiteSpace="pre"});let n=document.querySelector(".textTypeBasic"),r=0,l=setInterval(()=>{r<e.length?r<e[r].length?(n.innerText=e[r],r++):n.innerText="":clearInterval(l)},t),i=0,c=document.querySelector(".textTypeBasicLoop");setInterval(()=>{i<e.length?i<e[i].length?(c.innerText=e[i],i++):c.innerText="":i=0},t);let a=document.querySelector(".TextLetterTypeLoop"),o=0,s=0,T=!0;setInterval(()=>{o<e.length?1==T?(a.innerText+=e[o][s++],s==e[o].length&&(T=!1)):(s--,a.innerText=e[o].slice(0,s),0===s&&(a.innerText="",T=!0,o++)):o=0},t);let p=document.querySelector(".TextLetterTypeHide"),x=0,d=!0,u=0,y=setInterval(()=>{x<e.length?d?(p.innerText+=e[x][u++],u==e[x].length&&(d=!1)):(u--,p.innerText=e[x].slice(0,u),0==u&&(x++,d=!0,p.innerText="")):clearInterval(y)},t),h="parsa the perfect \n front end developer",f=document.querySelector(".TextparagraphType"),v=0,g=!0;setInterval(()=>{g?(f.innerText+=h[v++],39==v&&(g=!1)):(v--,f.innerText=h.slice(0,v),0===v&&(g=!0,f.innerText=""))},t)});