Socket
Socket
Sign inDemoInstall

typeit

Package Overview
Dependencies
Maintainers
1
Versions
119
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typeit - npm Package Compare versions

Comparing version 6.1.4 to 6.2.0

4

dist/typeit.es.min.js

@@ -5,3 +5,3 @@ /**

* Author: Alex MacArthur <alex@macarthur.me> (https://macarthur.me)
* Version: v6.1.4
* Version: v6.2.0
* License: GPL-2.0

@@ -11,2 +11,2 @@ * URL: https://typeitjs.com

*/
var t={strings:[],speed:100,cursor:!0,cursorChar:"|",cursorSpeed:1e3,deleteSpeed:null,lifeLike:!0,breakLines:!0,startDelay:250,startDelete:!1,nextStringDelay:750,loop:!1,loopDelay:750,html:!0,waitUntilVisible:!1,beforeString:()=>{},afterString:()=>{},beforeStep:()=>{},afterStep:()=>{},afterComplete:()=>{}};function e(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.insert=(t,e)=>{this.waiting.splice(t,0,e)},this.add=function(e){var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Array.isArray(e[0])?(t.waiting=t.waiting.concat(e),t):(t.waiting[i?"unshift":"push"](e),t)},this.delete=t=>(this.waiting.splice(t,1),this),this.reset=()=>(this.waiting=this.executed.concat(this.waiting),this.executed=[],this),this.executed=[],this.waiting=e,!e.length&&i&&this.add(i)}var i=t=>document.createElement(t);function s(t,e){return Math.abs(Math.random()*(t+e-(t-e))+(t-e))}function n(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",s=i("style");s.id=e,s.appendChild(document.createTextNode(t)),document.head.appendChild(s)}function r(t){return t.map(t=>t.replace(/<\!--.*?-->/g,""))}var a=t=>["textarea","input"].indexOf(t.tagName.toLowerCase())>-1,o=t=>Array.isArray(t)?t:[t],h=t=>[].slice.call(t),u=(t,e)=>{var i=t.nextSibling;return!!i&&!i.isEqualNode(e)};var l=(t,e)=>{var s=e;if(a(t))t.value="".concat(t.value).concat(s);else{var n=h(t.childNodes).filter(t=>t.classList&&t.classList.contains("ti-cursor"));if(n=n.length?n[0]:null,"object"==typeof e&&!(e instanceof HTMLElement)){var r=e.ancestorTree.slice(0).reverse().join(" "),o=h(t.querySelectorAll("".concat(r))),l=(o=o.filter(t=>!n||!n.isEqualNode(t))).length>0?o[o.length-1]:null;if(l&&((t,e)=>{if(!t)return!1;for(var i=!1,s=[],n=t;!i;)s.push(u(n,e)),(n=n.parentNode)&&n.hasAttribute&&!n.hasAttribute("data-typeit-id")||(i=!0);return!s.some(t=>t)})(l,n))t=l,s=e.content;else if(s=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=i(t);return e.forEach(t=>{n.setAttribute(t.name,t.value)}),n.innerHTML=s,n}(e.ancestorTree[0],e.attributes,e.content),e.ancestorTree.length>1){var c=h(t.querySelectorAll(e.ancestorTree[1]));t=c[c.length-1]}}s="object"==typeof s?s:document.createTextNode(s),t.insertBefore(s,n&&t.hasAttribute("data-typeit-id")?n:null)}},c=t=>{var e=[];return e.concat.apply(e,t)},p=t=>{var e=document.implementation.createHTMLDocument("");return e.body.innerHTML=t,e.body},d=t=>h(t.childNodes).map(t=>3===t.nodeType?t.nodeValue.split(""):t),f=(t,e,i)=>{return{ancestorTree:e,attributes:(s=t,h(s.attributes).map(t=>({name:t.name,value:t.nodeValue}))),content:i};var s},v=(t,e)=>{var i=f(t,e,""),s=d(t).map((i,s)=>Array.isArray(i)?i.map((i,s)=>f(t,e,i)):i);return s.unshift(i),c(s)},g=t=>t instanceof HTMLElement&&"BR"!==t.tagName,m=function t(e){var i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],s=e.map(t=>{if(g(t)){if(!i)return h(t.childNodes);for(var e=t.parentNode,s=[t.tagName];["BODY","HTML"].indexOf(e.tagName)<0;)s.push(e.tagName),e=e.parentNode;return v(t,s)}return t});return(s=c(s)).some(t=>g(t))?t(s,i):s};function y(t){var e=p(t),i=d(e);return m(i)}function b(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return e?y(t):t.split("")}var q=(t,e)=>{e?t.value="":t.querySelector(".ti-cursor")&&(t.innerHTML="")},w=function(t,e){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=!Array.isArray(t),n=t.length;return(t=s?new Array(t).fill(0):t).map((t,r)=>{if(s)return e;var a=[e,t];return i&&(0===r&&a.push({isFirst:!0}),r+1===n&&a.push({isLast:!0})),a})},S=t=>{t.parentNode.removeChild(t)},A=t=>3!==t.nodeType&&"BR"!==t.tagName&&!t.firstChild,N=t=>t.some(t=>A(t)),T=t=>{for(var e=h(t.querySelectorAll("*")),i=N(e);e.length&&i;){var s=!1;e.forEach(t=>{A(t)&&(S(t),s=!0)}),s&&(e=h(t.querySelectorAll("*"))),i=N(e)}return e},L=t=>(Array.isArray(t)||(t=[t/2,t/2]),{before:t[0],after:t[1],total:t[0]+t[1]});function x(t,e,i){var n=(e=null!==e?e:t/3)/2;return i?[s(t,t/2),s(e,n)]:[t,e]}function D(){var s=this,{typeIt:u,element:c,id:d,options:f,queue:v=[],isAReset:g=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},A=()=>{var t=h(this.$e.childNodes).filter(t=>!t.isEqualNode(O));return m(t,!1)},N=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=s.opts.nextStringDelay;s.queue.insert(t,[s.pause,i.before]),s.queue.insert(t+e+1,[s.pause,i.after])},$=()=>{if(P||!this.opts.cursor)return null;var t=i("span");return t.innerHTML=p(this.opts.cursorChar).innerHTML,t.className="ti-cursor",t.setAttribute("style","display:inline;position:relative;font:inherit;color:inherit;line-height:inherit;"),t},E=()=>{O&&(n("@keyframes blink-".concat(d," { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} }[data-typeit-id='").concat(d,"'] .ti-cursor { animation: blink-").concat(d," ").concat(this.opts.cursorSpeed/1e3,"s infinite; }"),d),this.$e.appendChild(O))};this.wait=function(t,e){this.timeouts.push(setTimeout(t,e))};var M=()=>{this.opts.strings.forEach((t,e)=>{var s=b(t,this.opts.html);this.queue.add(w(s,this.type,!0));var n=this.queue.waiting.length;if(e+1!==this.opts.strings.length){if(this.opts.breakLines)return this.queue.add([this.type,i("BR")]),void N(n);this.queue.add(w(s,this.delete)),N(n,t.length)}})},C=t=>{this.queue.reset().delete(0).add([this.pause,t.before],!0);for(var e=0;e<A().length;e++)this.queue.add([this.delete,null,{isPhantom:!0}],!0)},H=t=>{var e=this.$e.innerHTML;return e?(this.$e.innerHTML="",this.opts.startDelete?(y(e).forEach(t=>{l(this.$e,t)}),this.queue.add([this.delete,!0]),N(1),t):[e.trim()].concat(t)):t};this.pause=function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return new Promise((e,i)=>{this.wait(()=>e(),t||this.opts.nextStringDelay.total)})},this.reset=function(){return this.queue.reset(),new D({typeIt:u,element:this.$e,id:d,options:this.opts,queue:this.queue.waiting,isAReset:!0})},this.init=function(){if(!this.status.started){if(E(),!this.opts.waitUntilVisible)return this.status.started=!0,this.fire();new IntersectionObserver((t,e)=>{t.forEach(t=>{t.isIntersecting&&(this.fire(),e.unobserve(this.$e))})},{threshold:1}).observe(this.$e)}},this.fire=function(){for(var t=this,e=this.queue.waiting.slice(),i=Promise.resolve(),s=function(s){var n=e[s],r=[n,t.queue,u];i=i.then(()=>new Promise((e,i)=>{if(t.status.frozen)return i();t.pace=x(t.opts.speed,t.opts.deleteSpeed,t.opts.lifeLike),n[2]&&n[2].isFirst&&t.opts.beforeString(...r),t.opts.beforeStep(...r),n[0].call(t,n[1],n[2]).then(()=>{var i=t.queue.waiting.shift();return n[2]&&n[2].isPhantom?e():(n[2]&&n[2].isLast&&t.opts.afterString(...r),t.opts.afterStep(...r),t.queue.executed.push(i),e())})}))},n=0;n<e.length;n++)s(n);i.then(()=>{if(this.opts.loop){var t=this.opts.loopDelay?this.opts.loopDelay:this.opts.nextStringDelay;this.wait(()=>{C(t),this.fire()},t.after)}this.status.completed=!0,this.opts.afterComplete(u)}).catch(()=>{})},this.type=function(t){return"object"!=typeof t||t.content?new Promise(e=>{this.wait(()=>(l(this.$e,t),e()),this.pace[0])}):(l(this.$e,t),Promise.resolve())},this.empty=function(){return new Promise(t=>(P?this.$e.value="":h(this.$e.childNodes).forEach(t=>{O&&O.isEqualNode(t)||S(t)}),t()))},this.delete=function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return new Promise(e=>{this.wait(()=>{var i=A();return i.length&&S(i[i.length-1]),T(this.$e),t&&i.length-1>0?this.delete(!0).then(()=>e()):e()},this.pace[1])})},this.setOptions=function(t){return new Promise(e=>(this.opts=Object.assign({},this.opts,t),e()))};var P=a(c);this.status={started:!1,complete:!1,frozen:!1,destroyed:!1},this.$e=c,this.timeouts=[],this.opts=Object.assign({},t,f),this.opts.html=!P&&this.opts.html,this.opts.nextStringDelay=L(this.opts.nextStringDelay),this.opts.loopDelay=L(this.opts.loopDelay),this.queue=new e(v,[this.pause,this.opts.startDelay]),this.$e.setAttribute("data-typeit-id",d),n("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}"),q(c,P);var k=o(this.opts.strings);k=H(k),this.opts.strings=r(k);var O=$();this.opts.strings.length&&!g&&M()}export default function(t,e){var s,n=this;this.instances=(s=t,"string"==typeof s?s=document.querySelectorAll(s):s.forEach||(s=[s]),h(s)).map(t=>new D({typeIt:this,element:t,id:Math.random().toString(36).substring(2,15),options:e,queue:[],isAReset:!1}));var r=t=>{this.instances.forEach(e=>{t.call(this,e)})},a=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;r(s=>{var r="string"!=typeof t,a=r?t:s[t],o=w(i,[a,r?n:e]);s.queue.add(o)})};this.is=function(t){return e=this.instances,i=t,s=!0,!!e.length&&!e.some((function(t){return t.status[i]!==s}));var e,i,s},this.freeze=function(){r(t=>{t.status.frozen=!0})},this.unfreeze=function(){r(t=>{t.status.frozen&&(t.status.frozen=!1,t.fire())})},this.type=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return r(e=>{var i=b(t,e.opts.html);e.queue.add(w(i,e.type,!0))}),this},this.delete=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return a("delete",null===t,null===t?1:t),this},this.pause=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return a("pause",t),this},this.break=function(){return a("type",i("BR")),this},this.options=function(t){return a("setOptions",t),this},this.exec=function(t){return a(t),this},this.destroy=function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.instances=this.instances.map(e=>{if(e.timeouts.forEach(t=>{clearTimeout(t)}),e.timeouts=[],t){var i=e.isInput?null:e.$e.querySelector(".ti-cursor");i&&e.$e.removeChild(i)}return e.status.destroyed=!0,e})},this.empty=function(){return a("empty"),this},this.reset=function(){return this.destroy(),this.instances=this.instances.map(t=>t.reset()),this},this.go=function(){return r(t=>{t.init()}),this}}
var t={strings:[],speed:100,cursor:!0,cursorChar:"|",cursorSpeed:1e3,deleteSpeed:null,lifeLike:!0,breakLines:!0,startDelay:250,startDelete:!1,nextStringDelay:750,loop:!1,loopDelay:750,html:!0,waitUntilVisible:!1,beforeString:()=>{},afterString:()=>{},beforeStep:()=>{},afterStep:()=>{},afterComplete:()=>{}};function e(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.insert=(t,e)=>{this.waiting.splice(t,0,e)},this.add=function(e){var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Array.isArray(e[0])?(t.waiting=t.waiting.concat(e),t):(t.waiting[i?"unshift":"push"](e),t)},this.delete=t=>(this.waiting.splice(t,1),this),this.reset=()=>(this.waiting=this.executed.concat(this.waiting),this.executed=[],this),this.executed=[],this.waiting=e,!e.length&&i&&this.add(i)}var i=t=>document.createElement(t);function n(t,e){return Math.abs(Math.random()*(t+e-(t-e))+(t-e))}function r(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=i("style");n.id=e,n.appendChild(document.createTextNode(t)),document.head.appendChild(n)}function s(t){return t.map(t=>t.replace(/<\!--.*?-->/g,""))}var o=t=>["textarea","input"].indexOf(t.tagName.toLowerCase())>-1,a=t=>Array.isArray(t)?t:[t],u=t=>Array.from(t),h=(t,e)=>{var i=t.nextSibling;return!!i&&!i.isEqualNode(e)};var l=(t,e)=>{var n=e;if(o(t))t.value="".concat(t.value).concat(n);else{var r=u(t.childNodes).filter(t=>t.classList&&t.classList.contains("ti-cursor"));if(r=r.length?r[0]:null,"object"==typeof e&&!(e instanceof HTMLElement)){var s=e.ancestorTree.slice(0).reverse().join(" "),a=u(t.querySelectorAll("".concat(s))),l=(a=a.filter(t=>!r||!r.isEqualNode(t))).length>0?a[a.length-1]:null;if(l&&((t,e)=>{if(!t)return!1;for(var i=!1,n=[],r=t;!i;)n.push(h(r,e)),(r=r.parentNode)&&r.hasAttribute&&!r.hasAttribute("data-typeit-id")||(i=!0);return!n.some(t=>t)})(l,r))t=l,n=e.content;else if(n=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=i(t);return e.forEach(t=>{r.setAttribute(t.name,t.value)}),r.innerHTML=n,r}(e.ancestorTree[0],e.attributes,e.content),e.ancestorTree.length>1){var c=u(t.querySelectorAll(e.ancestorTree[1]));t=c[c.length-1]}}n="object"==typeof n?n:document.createTextNode(n),t.insertBefore(n,r&&t.hasAttribute("data-typeit-id")?r:null)}},c=t=>{var e=[];return e.concat.apply(e,t)},f=t=>{var e=document.implementation.createHTMLDocument("");return e.body.innerHTML=t,e.body},d=t=>u(t.childNodes).map(t=>3===t.nodeType?u(t.nodeValue):t),p=(t,e,i)=>{return{ancestorTree:e,attributes:(n=t,u(n.attributes).map(t=>({name:t.name,value:t.nodeValue}))),content:i};var n},v=(t,e)=>{var i=p(t,e,""),n=d(t).map((i,n)=>Array.isArray(i)?i.map((i,n)=>p(t,e,i)):i);return n.unshift(i),c(n)},g=t=>t instanceof HTMLElement&&"BR"!==t.tagName,y=function t(e){var i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=e.map(t=>{if(g(t)){if(!i)return u(t.childNodes);for(var e=t.parentNode,n=[t.tagName];["BODY","HTML"].indexOf(e.tagName)<0;)n.push(e.tagName),e=e.parentNode;return v(t,n)}return t});return(n=c(n)).some(t=>g(t))?t(n,i):n};function m(t){var e=f(t),i=d(e);return y(i)}function b(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return e?m(t):u(t)}var w=(t,e)=>{e?t.value="":t.querySelector(".ti-cursor")&&(t.innerHTML="")},q=function(t,e){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=!Array.isArray(t),r=t.length;return(t=n?new Array(t).fill(0):t).map((t,s)=>{if(n)return e;var o=[e,t];return i&&(0===s&&o.push({isFirst:!0}),s+1===r&&o.push({isLast:!0})),o})},S=t=>{t.parentNode.removeChild(t)},A=t=>3!==t.nodeType&&"BR"!==t.tagName&&!t.firstChild,N=t=>t.some(t=>A(t)),T=t=>{for(var e=u(t.querySelectorAll("*")),i=N(e);e.length&&i;){var n=!1;e.forEach(t=>{A(t)&&(S(t),n=!0)}),n&&(e=u(t.querySelectorAll("*"))),i=N(e)}return e},L=t=>(Array.isArray(t)||(t=[t/2,t/2]),{before:t[0],after:t[1],total:t[0]+t[1]});function $(t,e,i){var r=(e=null!==e?e:t/3)/2;return i?[n(t,t/2),n(e,r)]:[t,e]}function x(t,e,i){return i?e?e(t):t:(t&&t.then||(t=Promise.resolve(t)),e?t.then(e):t)}function D(t){return function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];try{return Promise.resolve(t.apply(this,e))}catch(t){return Promise.reject(t)}}}function E(){}function M(t,e){if(!e)return t&&t.then?t.then(E):Promise.resolve()}function C(t,e){var i=t();return i&&i.then?i.then(e):e(i)}function H(t){var e=t();if(e&&e.then)return e.then(E)}function P(t,e,i){if(!t.s){if(i instanceof k){if(!i.s)return void(i.o=P.bind(null,t,e));1&e&&(e=i.s),i=i.v}if(i&&i.then)return void i.then(P.bind(null,t,e),P.bind(null,t,2));t.s=e,t.v=i;var n=t.o;n&&n(t)}}var k=function(){function t(){}return t.prototype.then=function(e,i){var n=new t,r=this.s;if(r){var s=1&r?e:i;if(s){try{P(n,1,s(this.v))}catch(t){P(n,2,t)}return n}return this}return this.o=function(t){try{var r=t.v;1&t.s?P(n,1,e?e(r):r):i?P(n,1,i(r)):P(n,2,r)}catch(t){P(n,2,t)}},n},t}();function O(t,e,i){var n,r,s=-1;return function o(a){try{for(;++s<t.length&&(!i||!i());)if((a=e(s))&&a.then){if(!((u=a)instanceof k&&1&u.s))return void a.then(o,r||(r=P.bind(null,n=new k,2)));a=a.v}n?P(n,1,a):n=a}catch(t){P(n||(n=new k),2,t)}var u}(),n}function j(t,e){return t&&t.then?t.then(e):e(t)}function z(t,e){try{var i=t()}catch(t){return e(t)}return i&&i.then?i.then(void 0,e):i}function R(){var n=this,{typeIt:h,element:c,id:d,options:p,queue:v=[],isAReset:g=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},A=()=>{if(F)return u(this.$e.value);var t=u(this.$e.childNodes).filter(t=>!t.isEqualNode(Y));return y(t,!1)},N=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=n.opts.nextStringDelay;n.queue.insert(t,[n.pause,i.before]),n.queue.insert(t+e+1,[n.pause,i.after])},P=()=>{if(F||!this.opts.cursor)return null;var t=i("span");return t.innerHTML=f(this.opts.cursorChar).innerHTML,t.className="ti-cursor",t.setAttribute("style","display:inline;position:relative;font:inherit;color:inherit;line-height:inherit;"),t},k=()=>{Y&&(r("@keyframes blink-".concat(d," { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} }[data-typeit-id='").concat(d,"'] .ti-cursor { animation: blink-").concat(d," ").concat(this.opts.cursorSpeed/1e3,"s infinite; }"),d),this.$e.appendChild(Y))};this.wait=D((function(t,e){return this.timeouts.push(setTimeout(t,e)),x()}));var B=()=>{this.opts.strings.forEach((t,e)=>{var n=b(t,this.opts.html);this.queue.add(q(n,this.type,!0));var r=this.queue.waiting.length;if(e+1!==this.opts.strings.length){if(this.opts.breakLines)return this.queue.add([this.type,i("BR")]),void N(r);this.queue.add(q(n,this.delete)),N(r,t.length)}})},I=t=>{this.queue.reset().delete(0).add([this.pause,t.before],!0);for(var e=0;e<A().length;e++)this.queue.add([this.delete,null,{isPhantom:!0}],!0)},V=t=>{var e=this.$e.innerHTML;return e?(this.$e.innerHTML="",this.opts.startDelete?(m(e).forEach(t=>{l(this.$e,t)}),this.queue.add([this.delete,!0]),N(1),t):[e.trim()].concat(t)):t};this.pause=function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return new Promise((e,i)=>{this.wait(()=>e(),t||this.opts.nextStringDelay.total)})},this.reset=function(){return this.queue.reset(),new R({typeIt:h,element:this.$e,id:d,options:this.opts,queue:this.queue.waiting,isAReset:!0})},this.init=function(){if(!this.status.started){if(k(),!this.opts.waitUntilVisible)return this.status.started=!0,this.fire();new IntersectionObserver((t,e)=>{t.forEach(t=>{t.isIntersecting&&(this.fire(),e.unobserve(this.$e))})},{threshold:1}).observe(this.$e)}},this.fire=D((function(){var t=this,e=t.queue.waiting.slice();return z((function(){return j(O(e,(function(i){var n=e[i],r=[n,t.queue,h];if(t.status.frozen)throw new Error;return t.pace=$(t.opts.speed,t.opts.deleteSpeed,t.opts.lifeLike),C((function(){if(n[2]&&n[2].isFirst)return M(t.opts.beforeString(...r))}),(function(){return x(t.opts.beforeStep(...r),(function(){return x(n[0].call(t,n[1],n[2]),(function(){var e=t.queue.waiting.shift(),i=n[2]&&n[2].isPhantom;return H((function(){if(!i)return C((function(){if(n[2]&&n[2].isLast)return M(t.opts.afterString(...r))}),(function(){return x(t.opts.afterStep(...r),(function(){t.queue.executed.push(e)}))}))}))}))}))}))}),(function(){return!1})),(function(e){return t.status.completed=!0,x(t.opts.afterComplete(h),(function(){if(t.opts.loop){var e=t.opts.loopDelay?t.opts.loopDelay:t.opts.nextStringDelay;t.wait(()=>{I(e),t.fire()},e.after)}}))}))}),E)})),this.type=function(t){return"object"!=typeof t||t.content?new Promise(e=>{this.wait(()=>(l(this.$e,t),e()),this.pace[0])}):(l(this.$e,t),Promise.resolve())},this.empty=D((function(){F?this.$e.value="":u(this.$e.childNodes).forEach(t=>{Y&&Y.isEqualNode(t)||S(t)})})),this.delete=function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return new Promise(e=>{this.wait(()=>{var i=A();return i.length&&(F?this.$e.value=this.$e.value.slice(0,-1):S(i[i.length-1])),T(this.$e),t&&i.length-1>0?this.delete(!0).then(()=>e()):e()},this.pace[1])})},this.setOptions=D((function(t){this.opts=Object.assign({},this.opts,t)}));var F=o(c);this.status={started:!1,complete:!1,frozen:!1,destroyed:!1},this.$e=c,this.timeouts=[],this.opts=Object.assign({},t,p),this.opts.html=!F&&this.opts.html,this.opts.nextStringDelay=L(this.opts.nextStringDelay),this.opts.loopDelay=L(this.opts.loopDelay),this.queue=new e(v,[this.pause,this.opts.startDelay]),this.$e.setAttribute("data-typeit-id",d),r("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}"),w(c,F);var U=a(this.opts.strings);U=V(U),this.opts.strings=s(U);var Y=P();this.opts.strings.length&&!g&&B()}export default function(t,e){var n,r=this;this.instances=(n=t,"string"==typeof n?n=document.querySelectorAll(n):n.forEach||(n=[n]),u(n)).map(t=>new R({typeIt:this,element:t,id:Math.random().toString(36).substring(2,15),options:e,queue:[],isAReset:!1}));var s=t=>{this.instances.forEach(e=>{t.call(this,e)})},o=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;s(n=>{var s="string"!=typeof t,o=s?t:n[t],a=q(i,[o,s?r:e]);n.queue.add(a)})};this.is=function(t){return e=this.instances,i=t,n=!0,!!e.length&&!e.some((function(t){return t.status[i]!==n}));var e,i,n},this.freeze=function(){s(t=>{t.status.frozen=!0})},this.unfreeze=function(){s(t=>{t.status.frozen&&(t.status.frozen=!1,t.fire())})},this.type=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return s(e=>{var i=b(t,e.opts.html);e.queue.add(q(i,e.type,!0))}),this},this.delete=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return o("delete",null===t,null===t?1:t),this},this.pause=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return o("pause",t),this},this.break=function(){return o("type",i("BR")),this},this.options=function(t){return o("setOptions",t),this},this.exec=function(t){return o(t),this},this.destroy=function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.instances=this.instances.map(e=>{if(e.timeouts.forEach(t=>{clearTimeout(t)}),e.timeouts=[],t){var i=e.isInput?null:e.$e.querySelector(".ti-cursor");i&&e.$e.removeChild(i)}return e.status.destroyed=!0,e})},this.empty=function(){return o("empty"),this},this.reset=function(){return this.destroy(),this.instances=this.instances.map(t=>t.reset()),this},this.go=function(){return s(t=>{t.init()}),this}}

@@ -5,3 +5,3 @@ /**

* Author: Alex MacArthur <alex@macarthur.me> (https://macarthur.me)
* Version: v6.1.4
* Version: v6.2.0
* License: GPL-2.0

@@ -11,2 +11,2 @@ * URL: https://typeitjs.com

*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).TypeIt=e()}(this,(function(){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}var e={strings:[],speed:100,cursor:!0,cursorChar:"|",cursorSpeed:1e3,deleteSpeed:null,lifeLike:!0,breakLines:!0,startDelay:250,startDelete:!1,nextStringDelay:750,loop:!1,loopDelay:750,html:!0,waitUntilVisible:!1,beforeString:function(){},afterString:function(){},beforeStep:function(){},afterStep:function(){},afterComplete:function(){}};function n(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.insert=function(e,n){t.waiting.splice(e,0,n)},this.add=function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Array.isArray(e[0])?(t.waiting=t.waiting.concat(e),t):(t.waiting[n?"unshift":"push"](e),t)},this.delete=function(e){return t.waiting.splice(e,1),t},this.reset=function(){return t.waiting=t.executed.concat(t.waiting),t.executed=[],t},this.executed=[],this.waiting=e,!e.length&&n&&this.add(n)}var i=function(t){return document.createElement(t)};function r(t,e){return Math.abs(Math.random()*(t+e-(t-e))+(t-e))}function o(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=i("style");n.id=e,n.appendChild(document.createTextNode(t)),document.head.appendChild(n)}function u(t){return t.map((function(t){return t.replace(/<\!--.*?-->/g,"")}))}var s=function(t){return["textarea","input"].indexOf(t.tagName.toLowerCase())>-1},a=function(t){return Array.isArray(t)?t:[t]},c=function(t){return[].slice.call(t)},f=function(t,e){var n=t.nextSibling;return!!n&&!n.isEqualNode(e)};var l=function(e,n){var r=n;if(s(e))e.value="".concat(e.value).concat(r);else{var o=c(e.childNodes).filter((function(t){return t.classList&&t.classList.contains("ti-cursor")}));if(o=o.length?o[0]:null,"object"===t(n)&&!(n instanceof HTMLElement)){var u=n.ancestorTree.slice(0).reverse().join(" "),a=c(e.querySelectorAll("".concat(u))),l=(a=a.filter((function(t){return!o||!o.isEqualNode(t)}))).length>0?a[a.length-1]:null;if(l&&function(t,e){if(!t)return!1;for(var n=!1,i=[],r=t;!n;)i.push(f(r,e)),(r=r.parentNode)&&r.hasAttribute&&!r.hasAttribute("data-typeit-id")||(n=!0);return!i.some((function(t){return t}))}(l,o))e=l,r=n.content;else if(r=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=i(t);return e.forEach((function(t){r.setAttribute(t.name,t.value)})),r.innerHTML=n,r}(n.ancestorTree[0],n.attributes,n.content),n.ancestorTree.length>1){var h=c(e.querySelectorAll(n.ancestorTree[1]));e=h[h.length-1]}}r="object"===t(r)?r:document.createTextNode(r),e.insertBefore(r,o&&e.hasAttribute("data-typeit-id")?o:null)}},h=function(t){var e=[];return e.concat.apply(e,t)},p=function(t){var e=document.implementation.createHTMLDocument("");return e.body.innerHTML=t,e.body},d=function(t){return c(t.childNodes).map((function(t){return 3===t.nodeType?t.nodeValue.split(""):t}))},v=function(t,e,n){return{ancestorTree:e,attributes:(i=t,c(i.attributes).map((function(t){return{name:t.name,value:t.nodeValue}}))),content:n};var i},y=function(t,e){var n=v(t,e,""),i=d(t).map((function(n,i){return Array.isArray(n)?n.map((function(n,i){return v(t,e,n)})):n}));return i.unshift(n),h(i)},m=function(t){return t instanceof HTMLElement&&"BR"!==t.tagName},g=function t(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=e.map((function(t){if(m(t)){if(!n)return c(t.childNodes);for(var e=t.parentNode,i=[t.tagName];["BODY","HTML"].indexOf(e.tagName)<0;)i.push(e.tagName),e=e.parentNode;return y(t,i)}return t}));return(i=h(i)).some((function(t){return m(t)}))?t(i,n):i};function b(t){var e=p(t),n=d(e);return g(n)}function q(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return e?b(t):t.split("")}var w=function(t,e){e?t.value="":t.querySelector(".ti-cursor")&&(t.innerHTML="")},S=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=!Array.isArray(t),r=t.length;return(t=i?new Array(t).fill(0):t).map((function(t,o){if(i)return e;var u=[e,t];return n&&(0===o&&u.push({isFirst:!0}),o+1===r&&u.push({isLast:!0})),u}))},A=function(t){t.parentNode.removeChild(t)},T=function(t){return 3!==t.nodeType&&"BR"!==t.tagName&&!t.firstChild},N=function(t){return t.some((function(t){return T(t)}))},L=function(t){for(var e=c(t.querySelectorAll("*")),n=N(e);e.length&&n;){var i=!1;e.forEach((function(t){T(t)&&(A(t),i=!0)})),i&&(e=c(t.querySelectorAll("*"))),n=N(e)}return e},x=function(t){return Array.isArray(t)||(t=[t/2,t/2]),{before:t[0],after:t[1],total:t[0]+t[1]}};function D(t,e,n){var i=(e=null!==e?e:t/3)/2;return n?[r(t,t/2),r(e,i)]:[t,e]}function $(){var r=this,f=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},h=f.typeIt,d=f.element,v=f.id,y=f.options,m=f.queue,T=void 0===m?[]:m,N=f.isAReset,E=void 0!==N&&N,M=function(){var t=c(r.$e.childNodes).filter((function(t){return!t.isEqualNode(R)}));return g(t,!1)},C=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=r.opts.nextStringDelay;r.queue.insert(t,[r.pause,n.before]),r.queue.insert(t+e+1,[r.pause,n.after])},H=function(){if(z||!r.opts.cursor)return null;var t=i("span");return t.innerHTML=p(r.opts.cursorChar).innerHTML,t.className="ti-cursor",t.setAttribute("style","display:inline;position:relative;font:inherit;color:inherit;line-height:inherit;"),t},P=function(){R&&(o("@keyframes blink-".concat(v," { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} }[data-typeit-id='").concat(v,"'] .ti-cursor { animation: blink-").concat(v," ").concat(r.opts.cursorSpeed/1e3,"s infinite; }"),v),r.$e.appendChild(R))};this.wait=function(t,e){this.timeouts.push(setTimeout(t,e))};var k=function(){r.opts.strings.forEach((function(t,e){var n=q(t,r.opts.html);r.queue.add(S(n,r.type,!0));var o=r.queue.waiting.length;if(e+1!==r.opts.strings.length){if(r.opts.breakLines)return r.queue.add([r.type,i("BR")]),void C(o);r.queue.add(S(n,r.delete)),C(o,t.length)}}))},O=function(t){r.queue.reset().delete(0).add([r.pause,t.before],!0);for(var e=0;e<M().length;e++)r.queue.add([r.delete,null,{isPhantom:!0}],!0)},j=function(t){var e=r.$e.innerHTML;return e?(r.$e.innerHTML="",r.opts.startDelete?(b(e).forEach((function(t){l(r.$e,t)})),r.queue.add([r.delete,!0]),C(1),t):[e.trim()].concat(t)):t};this.pause=function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return new Promise((function(n,i){t.wait((function(){return n()}),e||t.opts.nextStringDelay.total)}))},this.reset=function(){return this.queue.reset(),new $({typeIt:h,element:this.$e,id:v,options:this.opts,queue:this.queue.waiting,isAReset:!0})},this.init=function(){var t=this;if(!this.status.started){if(P(),!this.opts.waitUntilVisible)return this.status.started=!0,this.fire();new IntersectionObserver((function(e,n){e.forEach((function(e){e.isIntersecting&&(t.fire(),n.unobserve(t.$e))}))}),{threshold:1}).observe(this.$e)}},this.fire=function(){for(var t=this,e=this.queue.waiting.slice(),n=Promise.resolve(),i=function(i){var r=e[i],o=[r,t.queue,h];n=n.then((function(){return new Promise((function(e,n){var i,u;if(t.status.frozen)return n();(t.pace=D(t.opts.speed,t.opts.deleteSpeed,t.opts.lifeLike),r[2]&&r[2].isFirst)&&(u=t.opts).beforeString.apply(u,o);(i=t.opts).beforeStep.apply(i,o),r[0].call(t,r[1],r[2]).then((function(){var n,i,u=t.queue.waiting.shift();if(r[2]&&r[2].isPhantom)return e();r[2]&&r[2].isLast&&(i=t.opts).afterString.apply(i,o);return(n=t.opts).afterStep.apply(n,o),t.queue.executed.push(u),e()}))}))}))},r=0;r<e.length;r++)i(r);n.then((function(){if(t.opts.loop){var e=t.opts.loopDelay?t.opts.loopDelay:t.opts.nextStringDelay;t.wait((function(){O(e),t.fire()}),e.after)}t.status.completed=!0,t.opts.afterComplete(h)})).catch((function(){}))},this.type=function(e){var n=this;return"object"!==t(e)||e.content?new Promise((function(t){n.wait((function(){return l(n.$e,e),t()}),n.pace[0])})):(l(this.$e,e),Promise.resolve())},this.empty=function(){var t=this;return new Promise((function(e){return z?t.$e.value="":c(t.$e.childNodes).forEach((function(t){R&&R.isEqualNode(t)||A(t)})),e()}))},this.delete=function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return new Promise((function(n){t.wait((function(){var i=M();return i.length&&A(i[i.length-1]),L(t.$e),e&&i.length-1>0?t.delete(!0).then((function(){return n()})):n()}),t.pace[1])}))},this.setOptions=function(t){var e=this;return new Promise((function(n){return e.opts=Object.assign({},e.opts,t),n()}))};var z=s(d);this.status={started:!1,complete:!1,frozen:!1,destroyed:!1},this.$e=d,this.timeouts=[],this.opts=Object.assign({},e,y),this.opts.html=!z&&this.opts.html,this.opts.nextStringDelay=x(this.opts.nextStringDelay),this.opts.loopDelay=x(this.opts.loopDelay),this.queue=new n(T,[this.pause,this.opts.startDelay]),this.$e.setAttribute("data-typeit-id",v),o("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}"),w(d,z);var I=a(this.opts.strings);I=j(I),this.opts.strings=u(I);var R=H();this.opts.strings.length&&!E&&k()}return function(t,e){var n,r=this;this.instances=(n=t,"string"==typeof n?n=document.querySelectorAll(n):n.forEach||(n=[n]),c(n)).map((function(t){return new $({typeIt:r,element:t,id:Math.random().toString(36).substring(2,15),options:e,queue:[],isAReset:!1})}));var o=function(t){r.instances.forEach((function(e){t.call(r,e)}))},u=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;o((function(i){var o="string"!=typeof t,u=o?t:i[t],s=S(n,[u,o?r:e]);i.queue.add(s)}))};this.is=function(t){return e=this.instances,n=t,i=!0,!!e.length&&!e.some((function(t){return t.status[n]!==i}));var e,n,i},this.freeze=function(){o((function(t){t.status.frozen=!0}))},this.unfreeze=function(){o((function(t){t.status.frozen&&(t.status.frozen=!1,t.fire())}))},this.type=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return o((function(e){var n=q(t,e.opts.html);e.queue.add(S(n,e.type,!0))})),this},this.delete=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return u("delete",null===t,null===t?1:t),this},this.pause=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return u("pause",t),this},this.break=function(){return u("type",i("BR")),this},this.options=function(t){return u("setOptions",t),this},this.exec=function(t){return u(t),this},this.destroy=function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.instances=this.instances.map((function(e){if(e.timeouts.forEach((function(t){clearTimeout(t)})),e.timeouts=[],t){var n=e.isInput?null:e.$e.querySelector(".ti-cursor");n&&e.$e.removeChild(n)}return e.status.destroyed=!0,e}))},this.empty=function(){return u("empty"),this},this.reset=function(){return this.destroy(),this.instances=this.instances.map((function(t){return t.reset()})),this},this.go=function(){return o((function(t){t.init()})),this}}}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).TypeIt=e()}(this,(function(){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}var e={strings:[],speed:100,cursor:!0,cursorChar:"|",cursorSpeed:1e3,deleteSpeed:null,lifeLike:!0,breakLines:!0,startDelay:250,startDelete:!1,nextStringDelay:750,loop:!1,loopDelay:750,html:!0,waitUntilVisible:!1,beforeString:function(){},afterString:function(){},beforeStep:function(){},afterStep:function(){},afterComplete:function(){}};function n(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.insert=function(e,n){t.waiting.splice(e,0,n)},this.add=function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Array.isArray(e[0])?(t.waiting=t.waiting.concat(e),t):(t.waiting[n?"unshift":"push"](e),t)},this.delete=function(e){return t.waiting.splice(e,1),t},this.reset=function(){return t.waiting=t.executed.concat(t.waiting),t.executed=[],t},this.executed=[],this.waiting=e,!e.length&&n&&this.add(n)}var i=function(t){return document.createElement(t)};function r(t,e){return Math.abs(Math.random()*(t+e-(t-e))+(t-e))}function o(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=i("style");n.id=e,n.appendChild(document.createTextNode(t)),document.head.appendChild(n)}function u(t){return t.map((function(t){return t.replace(/<\!--.*?-->/g,"")}))}var s=function(t){return["textarea","input"].indexOf(t.tagName.toLowerCase())>-1},a=function(t){return Array.isArray(t)?t:[t]},c=function(t){return Array.from(t)},f=function(t,e){var n=t.nextSibling;return!!n&&!n.isEqualNode(e)};var l=function(e,n){var r=n;if(s(e))e.value="".concat(e.value).concat(r);else{var o=c(e.childNodes).filter((function(t){return t.classList&&t.classList.contains("ti-cursor")}));if(o=o.length?o[0]:null,"object"===t(n)&&!(n instanceof HTMLElement)){var u=n.ancestorTree.slice(0).reverse().join(" "),a=c(e.querySelectorAll("".concat(u))),l=(a=a.filter((function(t){return!o||!o.isEqualNode(t)}))).length>0?a[a.length-1]:null;if(l&&function(t,e){if(!t)return!1;for(var n=!1,i=[],r=t;!n;)i.push(f(r,e)),(r=r.parentNode)&&r.hasAttribute&&!r.hasAttribute("data-typeit-id")||(n=!0);return!i.some((function(t){return t}))}(l,o))e=l,r=n.content;else if(r=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=i(t);return e.forEach((function(t){r.setAttribute(t.name,t.value)})),r.innerHTML=n,r}(n.ancestorTree[0],n.attributes,n.content),n.ancestorTree.length>1){var h=c(e.querySelectorAll(n.ancestorTree[1]));e=h[h.length-1]}}r="object"===t(r)?r:document.createTextNode(r),e.insertBefore(r,o&&e.hasAttribute("data-typeit-id")?o:null)}},h=function(t){var e=[];return e.concat.apply(e,t)},p=function(t){var e=document.implementation.createHTMLDocument("");return e.body.innerHTML=t,e.body},d=function(t){return c(t.childNodes).map((function(t){return 3===t.nodeType?c(t.nodeValue):t}))},v=function(t,e,n){return{ancestorTree:e,attributes:(i=t,c(i.attributes).map((function(t){return{name:t.name,value:t.nodeValue}}))),content:n};var i},y=function(t,e){var n=v(t,e,""),i=d(t).map((function(n,i){return Array.isArray(n)?n.map((function(n,i){return v(t,e,n)})):n}));return i.unshift(n),h(i)},m=function(t){return t instanceof HTMLElement&&"BR"!==t.tagName},g=function t(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=e.map((function(t){if(m(t)){if(!n)return c(t.childNodes);for(var e=t.parentNode,i=[t.tagName];["BODY","HTML"].indexOf(e.tagName)<0;)i.push(e.tagName),e=e.parentNode;return y(t,i)}return t}));return(i=h(i)).some((function(t){return m(t)}))?t(i,n):i};function b(t){var e=p(t),n=d(e);return g(n)}function w(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return e?b(t):c(t)}var q=function(t,e){e?t.value="":t.querySelector(".ti-cursor")&&(t.innerHTML="")},S=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=!Array.isArray(t),r=t.length;return(t=i?new Array(t).fill(0):t).map((function(t,o){if(i)return e;var u=[e,t];return n&&(0===o&&u.push({isFirst:!0}),o+1===r&&u.push({isLast:!0})),u}))},A=function(t){t.parentNode.removeChild(t)},T=function(t){return 3!==t.nodeType&&"BR"!==t.tagName&&!t.firstChild},N=function(t){return t.some((function(t){return T(t)}))},L=function(t){for(var e=c(t.querySelectorAll("*")),n=N(e);e.length&&n;){var i=!1;e.forEach((function(t){T(t)&&(A(t),i=!0)})),i&&(e=c(t.querySelectorAll("*"))),n=N(e)}return e},$=function(t){return Array.isArray(t)||(t=[t/2,t/2]),{before:t[0],after:t[1],total:t[0]+t[1]}};function x(t,e,n){var i=(e=null!==e?e:t/3)/2;return n?[r(t,t/2),r(e,i)]:[t,e]}function D(t,e,n){return n?e?e(t):t:(t&&t.then||(t=Promise.resolve(t)),e?t.then(e):t)}function E(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return Promise.resolve(t.apply(this,e))}catch(t){return Promise.reject(t)}}}function M(){}function C(t,e){if(!e)return t&&t.then?t.then(M):Promise.resolve()}function H(t,e){var n=t();return n&&n.then?n.then(e):e(n)}function P(t){var e=t();if(e&&e.then)return e.then(M)}function k(t,e,n){if(!t.s){if(n instanceof j){if(!n.s)return void(n.o=k.bind(null,t,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(k.bind(null,t,e),k.bind(null,t,2));t.s=e,t.v=n;var i=t.o;i&&i(t)}}var j=function(){function t(){}return t.prototype.then=function(e,n){var i=new t,r=this.s;if(r){var o=1&r?e:n;if(o){try{k(i,1,o(this.v))}catch(t){k(i,2,t)}return i}return this}return this.o=function(t){try{var r=t.v;1&t.s?k(i,1,e?e(r):r):n?k(i,1,n(r)):k(i,2,r)}catch(t){k(i,2,t)}},i},t}();function O(t,e,n){var i,r,o=-1;return function u(s){try{for(;++o<t.length&&(!n||!n());)if((s=e(o))&&s.then){if(!((a=s)instanceof j&&1&a.s))return void s.then(u,r||(r=k.bind(null,i=new j,2)));s=s.v}i?k(i,1,s):i=s}catch(t){k(i||(i=new j),2,t)}var a}(),i}function z(t,e){return t&&t.then?t.then(e):e(t)}function I(t,e){try{var n=t()}catch(t){return e(t)}return n&&n.then?n.then(void 0,e):n}function R(){var r=this,f=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},h=f.typeIt,d=f.element,v=f.id,y=f.options,m=f.queue,T=void 0===m?[]:m,N=f.isAReset,k=void 0!==N&&N,j=function(){if(J)return c(r.$e.value);var t=c(r.$e.childNodes).filter((function(t){return!t.isEqualNode(Q)}));return g(t,!1)},B=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=r.opts.nextStringDelay;r.queue.insert(t,[r.pause,n.before]),r.queue.insert(t+e+1,[r.pause,n.after])},V=function(){if(J||!r.opts.cursor)return null;var t=i("span");return t.innerHTML=p(r.opts.cursorChar).innerHTML,t.className="ti-cursor",t.setAttribute("style","display:inline;position:relative;font:inherit;color:inherit;line-height:inherit;"),t},F=function(){Q&&(o("@keyframes blink-".concat(v," { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} }[data-typeit-id='").concat(v,"'] .ti-cursor { animation: blink-").concat(v," ").concat(r.opts.cursorSpeed/1e3,"s infinite; }"),v),r.$e.appendChild(Q))};this.wait=E((function(t,e){return this.timeouts.push(setTimeout(t,e)),D()}));var U=function(){r.opts.strings.forEach((function(t,e){var n=w(t,r.opts.html);r.queue.add(S(n,r.type,!0));var o=r.queue.waiting.length;if(e+1!==r.opts.strings.length){if(r.opts.breakLines)return r.queue.add([r.type,i("BR")]),void B(o);r.queue.add(S(n,r.delete)),B(o,t.length)}}))},Y=function(t){r.queue.reset().delete(0).add([r.pause,t.before],!0);for(var e=0;e<j().length;e++)r.queue.add([r.delete,null,{isPhantom:!0}],!0)},G=function(t){var e=r.$e.innerHTML;return e?(r.$e.innerHTML="",r.opts.startDelete?(b(e).forEach((function(t){l(r.$e,t)})),r.queue.add([r.delete,!0]),B(1),t):[e.trim()].concat(t)):t};this.pause=function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return new Promise((function(n,i){t.wait((function(){return n()}),e||t.opts.nextStringDelay.total)}))},this.reset=function(){return this.queue.reset(),new R({typeIt:h,element:this.$e,id:v,options:this.opts,queue:this.queue.waiting,isAReset:!0})},this.init=function(){var t=this;if(!this.status.started){if(F(),!this.opts.waitUntilVisible)return this.status.started=!0,this.fire();new IntersectionObserver((function(e,n){e.forEach((function(e){e.isIntersecting&&(t.fire(),n.unobserve(t.$e))}))}),{threshold:1}).observe(this.$e)}},this.fire=E((function(){var t=this,e=t.queue.waiting.slice();return I((function(){return z(O(e,(function(n){var i=e[n],r=[i,t.queue,h];if(t.status.frozen)throw new Error;return t.pace=x(t.opts.speed,t.opts.deleteSpeed,t.opts.lifeLike),H((function(){var e;if(i[2]&&i[2].isFirst)return C((e=t.opts).beforeString.apply(e,r))}),(function(){var e;return D((e=t.opts).beforeStep.apply(e,r),(function(){return D(i[0].call(t,i[1],i[2]),(function(){var e=t.queue.waiting.shift(),n=i[2]&&i[2].isPhantom;return P((function(){if(!n)return H((function(){var e;if(i[2]&&i[2].isLast)return C((e=t.opts).afterString.apply(e,r))}),(function(){var n;return D((n=t.opts).afterStep.apply(n,r),(function(){t.queue.executed.push(e)}))}))}))}))}))}))}),(function(){return!1})),(function(e){return t.status.completed=!0,D(t.opts.afterComplete(h),(function(){if(t.opts.loop){var e=t.opts.loopDelay?t.opts.loopDelay:t.opts.nextStringDelay;t.wait((function(){Y(e),t.fire()}),e.after)}}))}))}),M)})),this.type=function(e){var n=this;return"object"!==t(e)||e.content?new Promise((function(t){n.wait((function(){return l(n.$e,e),t()}),n.pace[0])})):(l(this.$e,e),Promise.resolve())},this.empty=E((function(){J?this.$e.value="":c(this.$e.childNodes).forEach((function(t){Q&&Q.isEqualNode(t)||A(t)}))})),this.delete=function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return new Promise((function(n){t.wait((function(){var i=j();return i.length&&(J?t.$e.value=t.$e.value.slice(0,-1):A(i[i.length-1])),L(t.$e),e&&i.length-1>0?t.delete(!0).then((function(){return n()})):n()}),t.pace[1])}))},this.setOptions=E((function(t){this.opts=Object.assign({},this.opts,t)}));var J=s(d);this.status={started:!1,complete:!1,frozen:!1,destroyed:!1},this.$e=d,this.timeouts=[],this.opts=Object.assign({},e,y),this.opts.html=!J&&this.opts.html,this.opts.nextStringDelay=$(this.opts.nextStringDelay),this.opts.loopDelay=$(this.opts.loopDelay),this.queue=new n(T,[this.pause,this.opts.startDelay]),this.$e.setAttribute("data-typeit-id",v),o("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}"),q(d,J);var K=a(this.opts.strings);K=G(K),this.opts.strings=u(K);var Q=V();this.opts.strings.length&&!k&&U()}return function(t,e){var n,r=this;this.instances=(n=t,"string"==typeof n?n=document.querySelectorAll(n):n.forEach||(n=[n]),c(n)).map((function(t){return new R({typeIt:r,element:t,id:Math.random().toString(36).substring(2,15),options:e,queue:[],isAReset:!1})}));var o=function(t){r.instances.forEach((function(e){t.call(r,e)}))},u=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;o((function(i){var o="string"!=typeof t,u=o?t:i[t],s=S(n,[u,o?r:e]);i.queue.add(s)}))};this.is=function(t){return e=this.instances,n=t,i=!0,!!e.length&&!e.some((function(t){return t.status[n]!==i}));var e,n,i},this.freeze=function(){o((function(t){t.status.frozen=!0}))},this.unfreeze=function(){o((function(t){t.status.frozen&&(t.status.frozen=!1,t.fire())}))},this.type=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return o((function(e){var n=w(t,e.opts.html);e.queue.add(S(n,e.type,!0))})),this},this.delete=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return u("delete",null===t,null===t?1:t),this},this.pause=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return u("pause",t),this},this.break=function(){return u("type",i("BR")),this},this.options=function(t){return u("setOptions",t),this},this.exec=function(t){return u(t),this},this.destroy=function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.instances=this.instances.map((function(e){if(e.timeouts.forEach((function(t){clearTimeout(t)})),e.timeouts=[],t){var n=e.isInput?null:e.$e.querySelector(".ti-cursor");n&&e.$e.removeChild(n)}return e.status.destroyed=!0,e}))},this.empty=function(){return u("empty"),this},this.reset=function(){return this.destroy(),this.instances=this.instances.map((function(t){return t.reset()})),this},this.go=function(){return o((function(t){t.init()})),this}}}));
{
"name": "typeit",
"version": "6.1.4",
"version": "6.2.0",
"description": "The most versatile animated typing utility on the planet.",

@@ -46,2 +46,3 @@ "author": "Alex MacArthur <alex@macarthur.me> (https://macarthur.me)",

"babel-loader": "^8.0.6",
"babel-plugin-transform-async-to-promises": "^0.8.15",
"concurrently": "^4.1.2",

@@ -48,0 +49,0 @@ "express": "^4.17.1",

@@ -55,2 +55,3 @@ # TypeIt

- `Array.prototype.fill`
- `Array.from`
- `IntersectionObserver`

@@ -63,3 +64,3 @@ - `Object.assign`

```html
<script src="https://polyfill.io/v3/polyfill.min.js?features=Array.prototype.fill%2CIntersectionObserver%2CObject.assign%2CPromise"></script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=Array.prototype.fill%2CIntersectionObserver%2CObject.assign%2CPromise%2CArray.from"></script>
```

@@ -66,0 +67,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc