-
Notifications
You must be signed in to change notification settings - Fork 6
/
splt.esm.js
1 lines (1 loc) 路 1 KB
/
splt.esm.js
1
export default function splt({target:e=".splt",reveal:t=!1}){let l=[];const n=document.querySelectorAll(e);for(let e=0;e<n.length;e++){n[e].setAttribute("id","i"+[e+1]),l.push(n[e].innerHTML);const i=n[e].innerHTML.split("");for(let l=0;l<i.length;l++){const r=document.createElement("span");if(n[e].appendChild(r),r.setAttribute("id","c"+[l+1])," "==i[l])r.classList.add("whtSpc");else{r.classList.add("char");const e=document.querySelectorAll(".char");for(let t=0;t<e.length;t++)e[t].style.display="inline-block",e[t].style.overflow="hidden",e[t].style.verticalAlign="top"}if(1==t){const e=document.createElement("span");e.innerHTML=i[l],r.appendChild(e),e.setAttribute("id","r"),e.classList.add("reveal");const t=document.querySelectorAll(".reveal");for(let e=0;e<t.length;e++)t[e].style.display="inherit",t[e].style.overflow="inherit",t[e].style.verticalAlign="inherit"}else r.innerHTML=i[l]}n[e].removeChild(n[e].childNodes[0])}splt.revert=(()=>{for(let e=0;e<n.length;e++)n[e].removeAttribute("id"),n[e].innerHTML=l[e]})}