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.3 to 6.1.4

4

dist/typeit.es.min.js

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

* Author: Alex MacArthur <alex@macarthur.me> (https://macarthur.me)
* Version: v6.1.3
* Version: v6.1.4
* 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(H));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])},$=()=>{!P&&this.opts.cursor&&(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),(H=i("span")).innerHTML=p(this.opts.cursorChar).innerHTML,H.className="ti-cursor",H.setAttribute("style","display:inline;position:relative;font:inherit;color:inherit;line-height:inherit;"),this.$e.appendChild(H))};this.wait=function(t,e){this.timeouts.push(setTimeout(t,e))};var E=()=>{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)}})},M=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)},C=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($(),!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(()=>{M(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=>{H.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 H=null,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=C(k),this.opts.strings=r(k),this.opts.strings.length&&!g&&E()}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 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}}

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

* Author: Alex MacArthur <alex@macarthur.me> (https://macarthur.me)
* Version: v6.1.3
* Version: v6.1.4
* 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)},l=function(t,e){var n=t.nextSibling;return!!n&&!n.isEqualNode(e)};var f=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))),f=(a=a.filter((function(t){return!o||!o.isEqualNode(t)}))).length>0?a[a.length-1]:null;if(f&&function(t,e){if(!t)return!1;for(var n=!1,i=[],r=t;!n;)i.push(l(r,e)),(r=r.parentNode)&&r.hasAttribute&&!r.hasAttribute("data-typeit-id")||(n=!0);return!i.some((function(t){return t}))}(f,o))e=f,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,l=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},h=l.typeIt,d=l.element,v=l.id,y=l.options,m=l.queue,T=void 0===m?[]:m,N=l.isAReset,E=void 0!==N&&N,M=function(){var t=c(r.$e.childNodes).filter((function(t){return!t.isEqualNode(j)}));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(){!z&&r.opts.cursor&&(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),(j=i("span")).innerHTML=p(r.opts.cursorChar).innerHTML,j.className="ti-cursor",j.setAttribute("style","display:inline;position:relative;font:inherit;color:inherit;line-height:inherit;"),r.$e.appendChild(j))};this.wait=function(t,e){this.timeouts.push(setTimeout(t,e))};var P=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)}}))},k=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)},O=function(t){var e=r.$e.innerHTML;return e?(r.$e.innerHTML="",r.opts.startDelete?(b(e).forEach((function(t){f(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(H(),!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(){k(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 f(n.$e,e),t()}),n.pace[0])})):(f(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){j.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 j=null,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=O(I),this.opts.strings=u(I),this.opts.strings.length&&!E&&P()}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[].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}}}));
{
"name": "typeit",
"version": "6.1.3",
"version": "6.1.4",
"description": "The most versatile animated typing utility on the planet.",

@@ -5,0 +5,0 @@ "author": "Alex MacArthur <alex@macarthur.me> (https://macarthur.me)",

@@ -46,2 +46,6 @@ # TypeIt

## Looking for a React Component?
Check out the official [React component for TypeIt](https://github.com/alexmacarthur/typeit-react) here.
## Browser Support

@@ -48,0 +52,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