hexo-theme-async
Version:
🎈 A simple, lightweight Hexo theme
2 lines (1 loc) • 583 B
JavaScript
(()=>{var I=document.querySelector(".trm-typed-text"),u=window.ASYNC_CONFIG.typed_text||[];function y(i,e){if(!i||!Array.isArray(e)||Array.isArray(e)&&!e.length)return;let T=100,A=3e3,o=0,c=1,n=o,r=0,t=0,s;l();function l(){s=setInterval(a,T)}function a(){let d=e[r];n==o?(t++,t==d.length&&(n=c,clearInterval(s),setTimeout(l,A))):n==c&&(t--,t==0&&f());let p=d.substring(0,t);i.textContent=p}function f(){t=0,n=o,r++,r==e.length&&(r=0)}}y(I,u);window.ASYNC_CONFIG.swup&&document.addEventListener("swup:contentReplaced",function(){y(document.querySelector(".trm-typed-text"),u)});})();