-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.min.js
1 lines (1 loc) · 1.18 KB
/
index.min.js
1
function wiatal(e,t){let l,r=0,n=setTimeout,o=setInterval,a=clearInterval,s=console.error,d=()=>{let e=0;r==l&&(r=0,e=t.loopDelay),n((()=>{i(t.strings[r])}),t.startDelay+e)},i=l=>{let r=0,n=l.length,a=o((()=>{if(t.placeholder?e.placeholder+=l[r]:e.textContent+=l[r],++r==n)return c(a)}),t.typeSpeed)},c=e=>{if(a(e),(t.disableBacktyping||!t.loop)&&r==l-1)return t.onFinished();n((()=>p()),t.backDelay)},p=()=>{let l=t.placeholder?e.placeholder:e.textContent,r=l.length,n=o((()=>{if(t.placeholder?e.placeholder=l.substr(0,--r):e.textContent=l.substr(0,--r),0==r)return h(n)}),t.backSpeed)},h=e=>{a(e),++r,d()};e?(t=(e=>{let t={strings:["Put your strings here...","and Enjoy!"],typeSpeed:150,backSpeed:50,backDelay:500,startDelay:500,loopDelay:0,cursorChar:"|",placeholder:!1,showCursor:!0,disableBacktyping:!1,onFinished:()=>{},loop:!0};e=e||{};for(let l in e)t[l]=e[l];return t})(t),l=t.strings.length,"string"==typeof e&&(e=document.querySelector(e)),e?(t.showCursor&&!t.placeholder&&(()=>{let l=e,r=document.createElement("span");r.classList.add("ityped-cursor"),r.textContent=t.cursorChar,l.insertAdjacentElement("afterend",r)})(),d()):s("wiatal: element does not exist")):s("wiatal: no element defined")}