-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtyper-experiment.39a76917.js
More file actions
1 lines (1 loc) · 10 KB
/
Copy pathtyper-experiment.39a76917.js
File metadata and controls
1 lines (1 loc) · 10 KB
1
parcelRequire=function(e){var r="function"==typeof parcelRequire&&parcelRequire,n="function"==typeof require&&require,i={};function u(e,u){if(e in i)return i[e];var t="function"==typeof parcelRequire&&parcelRequire;if(!u&&t)return t(e,!0);if(r)return r(e,!0);if(n&&"string"==typeof e)return n(e);var o=new Error("Cannot find module '"+e+"'");throw o.code="MODULE_NOT_FOUND",o}return u.register=function(e,r){i[e]=r},i=e(u),u.modules=i,u}(function (require) {function q(a){return a&&a.__esModule?{d:a.default}:{d:a}}var k,j={};function b(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(e){return(w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(e,t){"object"===(void 0===j?"undefined":w(j))?j=t():"function"==typeof k&&k.amd?k(t):(e="undefined"!=typeof globalThis?globalThis:e||self).typer=t()}(j,function(){var e=["typer","cursor-block","cursor-soft","cursor-hard","no-cursor"],t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@$^*()";return function(n,r){var i=[],o=document.body,a={},c=0;if("String"===s(n)&&(n=document.querySelector(n)),n.getAttribute("data-typer"))throw new Error("You've already called Typer on this element.");r=f(r),i.speedSet=!0,i.voids=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"],i.classNames=e,i.id=function e(t){return t?(t^16*Math.random()>>t/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e)}(),n.setAttribute("data-typer",i.id);var u={cursor:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(i.cursorRan)return this;if(i.cursorRan=!0,!1===e)return i.cursor="no-cursor",this;var t=e.color,n=e.blink,r=e.block,o=[];return t&&function(e,t){i.style=document.createElement("style"),i.style.appendChild(document.createTextNode("")),document.head.appendChild(i.style);var n=document.styleSheets[document.styleSheets.length-1];"insertRule"in n?n.insertRule("".concat(e,"{").concat(t,"}"),0):n.addRule(e,t)}("[data-typer=\"".concat(i.id,"\"] .typer::after"),"background-color:".concat(t)),o.push("hard"===n?"cursor-hard":"cursor-soft"),!0===r&&o.push("cursor-block"),i.cursor=o.join(" "),this},line:function(e,t){return p("line",e,t),i.typing||(i.typing=!0,m()),this},continue:function(e,t){return p("continue",e,t),this},military:function(e,t){return p("military",e,t),i.typing||(i.typing=!0,m()),this},pause:function(e){return i.push({pause:+e||500}),this},emit:function(e,t){return t?"String"===s(t)&&(t=document.querySelector(t)):t=o,i.push({emit:e,el:t}),this},listen:function(e,t){return t?"String"===s(t)&&(t=document.querySelector(t)):t=o,i.push({listen:e,el:t}),this},back:function(e,t){return i.push({back:e,speed:t}),this},empty:function(){return i.push({empty:!0}),this},run:function(e){return i.push({run:e}),this},end:function(e,t){return i.push({end:!0}),i.cb=function(){return d(e,t)},g("end")},halt:function(){if(!i.typing)return this;i.halt=!0},resume:function(){if(!i.typing)return this;i.complete||(i.halt=!1,i.resume(),i.resume=null)},repeat:function(e,t){return i.push({repeat:!0,num:e,shouldEmpty:t,id:c++}),this},kill:$};function l(e){return{}.toString.call(e).slice(8,-1)}function s(e){var t=l(e);if("html"!==t.slice(0,4).toLowerCase()&&"String"!==t)throw"You need to provide a string selector, such as '.some-class', or an html element.";return t}function f(e){var t=l(e);if(void 0===e)return i.speedSet?r:70;if("Number"===t&&!isNaN(e))return e;if("Object"===t){var n=e.hasOwnProperty("min"),o=e.hasOwnProperty("max"),a=e.hasOwnProperty("speed");if(a&&!isNaN(e.speed))return e.speed;if(n&&o&&e.min<e.max)return e;if(!Object.keys(e).length&&i.speedSet)return r;if(!n&&!o&&!a)return r}throw new Error("You have provided an invalid value for speed.")}function d(e,t){i.style&&i.style.remove(),i.newDiv&&v(),n.removeAttribute("data-typer"),o.removeEventListener("killTyper",$),i.newDiv&&i.newDiv.classList.add("white-space"),i.newDiv="","function"==typeof e?e(n):"function"==typeof t&&t(n),!0!==e&&!0!==t||o.dispatchEvent(new Event("typerFinished"))}function v(){e.forEach(function(e){return i.newDiv.classList.remove(e)})}function p(e,t,n){var r="line"===e,o="continue"===e;if(t||n){if("Object"===l(t))(r||o&&t.container)&&i.push(c(t));else if(isNaN(n))i.push(c(n,t));else{var a;i.push((b(a={},e,t),b(a,"speed",f(n)),b(a,"html",!0),a))}}else r&&i.push({line:1});function c(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0,o=n.container,a=n.totalTime,c=n.military,u=!i&&("String"===l(o)?document.querySelector(o).textContent:o.textContent);return b(t={},e,i||u),b(t,"speed",f(n)),b(t,"html",!1!==n.html),b(t,"element",r?n.element:null),b(t,"military",function(e){if(!e)return null;if(+e)return{speed:+e,chars:3};if("Object"===l(e))return{speed:+e.speed||50,chars:+e.chars||3};throw new Error("You have provided an invalid value for military.")}(c)),b(t,"totalTime",a),t}}function m(){if(i.item>=0||(i.item=0),i.item===i.length)return i.complete=!0,o.removeEventListener("killTyper",$);i.ks||(i.ks=!0,o.addEventListener("killTyper",$)),i.cursor||(i.cursor="cursor-soft"),i.type=setInterval(function(){if(!i.length)return clearInterval(i.type);var e,t=i[i.item];t.line?h(t):t.continue?function(e){clearInterval(i.type),T(e)}(t):t.pause?function(e){clearInterval(i.type),i.pause=setTimeout(function(){i.pause=null,i.item++,m()},e.pause)}(t):t.emit?function(e){clearInterval(i.type),e.el.dispatchEvent(new Event(e.emit)),i.item++,m()}(t):t.listen?function(e){var t=e.el,n=e.listen;function r(e){i.listening=!1,t.removeEventListener(e.type,r),i.killed||(i.item++,m())}clearInterval(i.type),i.listening=!0,t.addEventListener(n,r),a={el:t,type:n,fxn:r}}(t):t.back?function(e){var t=e.back,n=e.speed;if(clearInterval(i.type),!i.newDiv||!i.newDiv.textContent)return i.item++,m();var o=function e(t){var n=0;return Array.from(t.childNodes).forEach(function(t){i.voids.includes(t.nodeName)&&n++,t.childNodes.length&&(n+=e(t))}),n}(i.newDiv),a=i.newDiv.textContent.length;if("empty"===t){if(!n||n>=a)i.newDiv.innerHTML="";else{var c=i.newDiv.cloneNode(!0),u=s(c);n<0&&(n+=a);for(var l=0;l<n;l++)u();f(c),i.newDiv.innerHTML=c.innerHTML}return i.item++,m()}function s(e){var o=0,a=function e(t){var n=[],r=Array.from(t.childNodes);return r.length?(r.forEach(function(t){t.childNodes.length?n=n.concat(e(t)):n.push(t)}),n):n}(e||i.newDiv).reverse();return function c(){if(i.halt)return i.resume=function(){return i.goBack=setInterval(c,n||r)},clearInterval(i.goBack);var u=a[0];i.voids.includes(u.nodeName)?(u.remove(),a.shift()):(u.textContent=u.textContent.slice(0,-1),u.length||a.shift()),e||++o===t&&(clearInterval(i.goBack),f(i.newDiv),i.item++,m())}}function f(e){Array.from(e.childNodes).forEach(function(e){i.voids.includes(e.nodeName)||(e.childNodes.length&&f(e),"#text"===e.nodeName||e.innerHTML.length||e.remove(),"#text"!==e.nodeName||e.length||e.remove())})}t>a+o&&(t="all"),"all"===t&&(t=a+o),t<0&&(t=a+o- -1*t),i.goBack=setInterval(s(),n||r)}(t):t.empty?(n.innerHTML="",h({line:1})):t.run?(e=t.run,clearInterval(i.type),e(n),i.item++,m()):t.repeat?function(e){if(clearInterval(i.type),e.shouldEmpty&&(n.innerHTML=""),e.num){e.num--;var t=i.findIndex(function(t){var n=t.repeat,r=t.id;return n&&r===e.id-1})+1;i.item=t}else i.item++;m()}(t):t.end&&(clearInterval(i.type),i.cb())},0)}function h(e){clearInterval(i.type),i.newDiv&&(v(),i.newDiv.classList.add("white-space"),i.newDiv.innerHTML||(i.newDiv.innerHTML=" "));var t=document.createElement(e.element||"div");if(t.setAttribute("data-typer-child",i.id),t.className="".concat(i.cursor," typer white-space"),n.appendChild(t),i.newDiv=t,1===e.line)return i.item++,m();T(e)}function y(e,t){var n,r,o="Object"===l(e)?(n=e.min,r=e.max,Math.floor(Math.random()*(r-n+1)+n)):e;i.halt?i.resume=function(){return i.iterator=setTimeout(t,o)}:i.iterator=setTimeout(t,o)}function T(e){var n,r,o=e.line||e.continue,a=document.createElement("div");if(Array.isArray(o))return n=0,void y(r=e.totalTime?e.totalTime/o.length:e.speed,function t(){var c=o[n++];a.textContent=c,i.newDiv.innerHTML+=e.html?c:a.innerHTML,n===o.length?s():y(r,t)});function c(){return t[Math.floor(Math.random()*t.length)]}function u(t,n,r){var o=0,a=e.military,u=a.speed,l=a.chars;t.innerHTML+=c(),i.military=setInterval(function(){if(o===l)return t.innerHTML=t.innerHTML.slice(0,-1)+n,clearInterval(i.military),r();t.innerHTML=t.innerHTML.slice(0,-1)+c(),o++},u)}function s(){return clearInterval(i.iterator),i.item++,m()}a.innerHTML=o,e.html?function(){var t=function e(t,n){var r=[];t=Array.from(t);for(var o=0;o<t.length;o++){var a=t[o],c=a.nodeName;"#text"===c?r.push({parent:n,content:a.textContent}):a.childNodes.length?function(){var t=document.createElement(c);Array.from(a.attributes).forEach(function(e){t.setAttribute(e.name,e.value)}),r.push({parent:n,newNode:t}),r=r.concat(e(a.childNodes,t))}():i.voids.includes(c)&&r.push({parent:n,voidNode:a})}return r}(a.childNodes,i.newDiv),n=0,r=0,o=t[n++],c=e.totalTime?e.totalTime/o.content.length:e.speed;y(c,function i(){if(o.content&&r===o.content.length&&(r=0,o=t[n++]),!o)return s();if(o.content){if(e.military)return u(o.parent,o.content[r++],function(){y(c,i)});o.parent.innerHTML+=o.content[r++]}else o.parent.appendChild(o.voidNode||o.newNode),o=t[n++];y(c,i)})}():function(){var t=0,n=e.totalTime?e.totalTime/o.length:e.speed;y(n,function r(){if(t===o.length)return s();var c=o[t];if(e.military)return u(i.newDiv,c,function(){t++,y(n,r)});"String"!==l(o)&&(a.textContent=c,c=a.innerHTML),i.newDiv.innerHTML+=c,t++,y(n,r)})}()}function $(){return i.typing?(a.el&&a.el.removeEventListener(a.type,a.fxn),clearInterval(i.type),clearInterval(i.iterator),clearInterval(i.goBack),clearInterval(i.military),clearTimeout(i.pause),d(),g("kill")):u}function g(e){var t=function(){return u};return Object.keys(u).forEach(function(n){"end"===e&&"kill"===n||(u[n]=t)}),"kill"===e&&(i.killed=!0),u}return u}});var x=q(j);x.d(document.body,{min:20,max:350}).line("Humanizing the speed will look more, uh, human.");return{"Focm":{}};});