1
|
var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var ChangingTitle=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;_classCallCheck(this,e),this.node=t,this.letterfy(this.node.querySelector("h1"))}return _createClass(e,[{key:"letterfy",value:function(e){var t=e.innerText;e.innerText="",e.classList.add("current");for(var n in t){var r=document.createElement("span");r.innerText=t[n],r.classList.add("letter","in"),r.style.animationDelay=.1*n+"s",e.appendChild(r)}}},{key:"changeText",value:function(e){var t=this.node.querySelector(".current"),n=0,r=!0,a=!1,i=void 0;try{for(var l,o=t.children[Symbol.iterator]();!(r=(l=o.next()).done);r=!0){var c=l.value;c.style.animationDelay=.1*n+++"s",c.classList.remove("in"),c.classList.add("out")}}catch(e){a=!0,i=e}finally{try{!r&&o.return&&o.return()}finally{if(a)throw i}}t.classList.remove("current");var s=document.createElement("h1");s.classList.add("current");for(var u in e){var d=document.createElement("span");d.innerText=e[u],d.classList.add("letter","in"),d.style.animationDelay=.1*u+.5+"s",s.appendChild(d)}this.node.appendChild(s),setTimeout(this.removeNode(t),2e3)}},{key:"removeNode",value:function(e){return function(){e.remove()}}}]),e}(),ct=new ChangingTitle(document.querySelector(".changing-title")),texts=["Hi! I am नवन"],count=0;setInterval(function(){ct.changeText(texts[++count%texts.length])},2e3);
|