From 2c10cfcf30f36da4b596ae8586c4ee12ca141bb6 Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Sun, 21 Jan 2018 17:51:46 +0530 Subject: Update index.js --- js/index.js | 94 +------------------------------------------------------------ 1 file changed, 1 insertion(+), 93 deletions(-) (limited to 'js') diff --git a/js/index.js b/js/index.js index c5340b8..816434f 100644 --- a/js/index.js +++ b/js/index.js @@ -1,93 +1 @@ -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var ChangingTitle = function () { - function ChangingTitle() { - var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; - - _classCallCheck(this, ChangingTitle); - - this.node = x; - this.letterfy(this.node.querySelector('h1')); - } - - _createClass(ChangingTitle, [{ - key: 'letterfy', - value: function letterfy(node) { - var text = node.innerText; - node.innerText = ''; - node.classList.add('current'); - for (var c in text) { - var span = document.createElement('span'); - span.innerText = text[c]; - span.classList.add('letter', 'in'); - span.style.animationDelay = c * 0.1 + 's'; - node.appendChild(span); - } - } - }, { - key: 'changeText', - value: function changeText(newText) { - var oldTitle = this.node.querySelector('.current'); - var i = 0; - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = oldTitle.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var letter = _step.value; - - letter.style.animationDelay = i++ * 0.1 + 's'; - letter.classList.remove('in'); - letter.classList.add('out'); - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - - oldTitle.classList.remove('current'); - var newTitle = document.createElement('h1'); - newTitle.classList.add('current'); - for (var c in newText) { - var span = document.createElement('span'); - span.innerText = newText[c]; - span.classList.add('letter', 'in'); - span.style.animationDelay = c * 0.1 + 0.5 + 's'; - newTitle.appendChild(span); - } - this.node.appendChild(newTitle); - setTimeout(this.removeNode(oldTitle), 2000); - } - }, { - key: 'removeNode', - value: function removeNode(x) { - return function () { - x.remove(); - }; - } - }]); - - return ChangingTitle; -}(); - -; - -var ct = new ChangingTitle(document.querySelector('.changing-title')); -var texts = ['Hi! I am नवन']; -var count = 0; -setInterval(function () { - ct.changeText(texts[++count % texts.length]); -}, 2000); +var _createClass=function(){function e(e,t){for(var n=0;n0&&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); -- cgit v1.2.3