Comparing version 7.0.0-rc9 to 7.0.0
/** | ||
* TypeIt - The most versatile animated typing utility on the planet. | ||
* Author: Alex MacArthur <alex@macarthur.me> (https://macarthur.me) | ||
* Version: v7.0.0-rc9 | ||
* Version: v7.0.0 | ||
* License: GPL-2.0 | ||
* URL: https://typeitjs.com | ||
*/ | ||
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:()=>{},afterString:()=>{},beforeStep:()=>{},afterStep:()=>{},afterComplete:()=>{}},t=e=>e.map(e=>(void 0===e[1]&&e.push(null),void 0===e[2]&&e.push({}),e)),n=(e,t)=>Object.assign({},e,t),r=e=>Array.isArray(e),i=(e,t)=>(e[2]=n(e[2],t)||t,e),o=(e,t)=>r(e[0])?e.map(e=>i(e,t)):i(e,t),a=(e,t,n,i)=>{i=i||!1,n=n||{};var a=!r(e),u=e.length;return(e=a?new Array(e).fill(0):e).map((e,r)=>{if(a)return t;var c=[t,e,n];return i&&(0===r&&(c=o(c,{isFirst:!0})),r+1===u&&(c=o(c,{isLast:!0}))),c})};function u(e){this.insert=function(e,t){n.splice(e,0,t)},this.add=function(e,t,i){return e=r(e)?e:[e,null],i=i||!1,t=t||1,r(e[0])||(e=a(t,e)),n=i?e.concat(n):n.concat(e),this},this.delete=function(e){return n.splice(e,1),this},this.reset=function(){return n=t(n).map(e=>(e[2].executed=!1,e)),this},this.getItems=function(){return t(n).filter(e=>!e.executed)};var n=[];e&&this.add(e)}var c=e=>Array.from(e),s=e=>{var t=[];return t.concat.apply(t,e)},l=e=>{var t=document.implementation.createHTMLDocument("");return t.body.innerHTML=e,t.body},f=(e,t,n)=>{t=t||null,n=void 0!==n&&n;var r=c(e.childNodes).map(e=>{return 3===(t=e).nodeType||"BR"===t.tagName?e:f(e);var t});return r=s(r),t&&(r=r.filter(e=>!e.parentNode.isEqualNode(t))),n?r.reverse():r},d=e=>"BODY"===e.tagName,h=(e,t)=>{t=t||null;var n=e instanceof HTMLElement;return{node:t,isTopLevelText:(!t||d(t.parentNode))&&!n,isHTMLElement:n,content:e}};function p(e){var t,n=l(e);return t=f(n).map(e=>e.nodeValue?c(e.nodeValue).map(t=>h(t,e)):h(e)),s(t)}function v(e,t){return(t=void 0===t||t)?p(e):c(e).map(e=>h(e))}var m=e=>document.createElement(e),y=(e,t)=>{var n=m("style");n.id=t||"",n.appendChild(document.createTextNode(e)),document.head.appendChild(n)},g=e=>(r(e)||(e=[e/2,e/2]),{before:e[0],after:e[1],total:e[0]+e[1]}),b=(e,t)=>Math.abs(Math.random()*(e+t-(e-t))+(e-t));var N=e=>["textarea","input"].indexOf(e.tagName.toLowerCase())>-1,S=(e,t)=>{var n=t.querySelectorAll("*");return[t].concat(c(n).reverse()).find(t=>t.cloneNode().outerHTML===e.outerHTML)},T=(e,t,n,r)=>{n=n||null;var i=t.isHTMLElement,o=i?t.content:document.createTextNode(t.content);if(N(e))e.value="".concat(e.value).concat(t.content);else{if(!t.isTopLevelText&&!i){var a=t.node.parentNode,u=S(a.cloneNode(),e);if(((e,t)=>{if(!e)return!1;var n=e.nextSibling;return!n||n.isEqualNode(t)})(u,n))e=u;else if((o=a.cloneNode()).innerText=t.content,!d(a.parentNode)){for(var c=a.parentNode,s=c.cloneNode(),l=S(s,e);!l&&!d(c);)s.innerHTML=o.outerHTML,o=s,s=c.parentNode.cloneNode(),c=c.parentNode,l=S(s,e);e=l||e}}var h=f(e,n,!0)[r-1],p=h?h.parentNode:e;p.insertBefore(o,p.contains(n)?n:null)}},L=e=>e&&e.parentNode.removeChild(e);var x=(e,t,n)=>{var r,i="string"==typeof e,o=!1,a=-1*e;return i&&(a=(r="END"===e.toUpperCase())?-1:1,o=r?t+a>0:t+a<n.length),{isString:i,numberOfSteps:a,canKeepMoving:o}},M=e=>{var t,n=["font","lineHeight","color"],r=m("SPAN"),i=(t=e,window.getComputedStyle(t,null));for(var o in i)n.indexOf(o)>-1&&i[o]&&(r.style[o]=i[o]);return r.style.cssText};function w(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function E(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{return Promise.resolve(e.apply(this,t))}catch(e){return Promise.reject(e)}}}function D(){}function H(e,t){if(!t)return e&&e.then?e.then(D):Promise.resolve()}function C(e,t){var n=e();return n&&n.then?n.then(t):t(n)}function A(e,t,n){if(!e.s){if(n instanceof P){if(!n.s)return void(n.o=A.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(A.bind(null,e,t),A.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var P=function(){function e(){}return e.prototype.then=function(t,n){var r=new e,i=this.s;if(i){var o=1&i?t:n;if(o){try{A(r,1,o(this.v))}catch(e){A(r,2,e)}return r}return this}return this.o=function(e){try{var i=e.v;1&e.s?A(r,1,t?t(i):i):n?A(r,1,n(i)):A(r,2,i)}catch(e){A(r,2,e)}},r},e}();function k(e,t){return e&&e.then?e.then(t):t(e)}export default function(t,i){var o=this;i=i||{};var s=(e,t,n)=>(e=r(e[0])?e:[e],oe.add(e,t),(e=>{var t=(e=e||{}).delay;t&&oe.add([V,t])})(n),this),d=e=>[[F,e="object"==typeof e?e:{},{force:!0}],[F,ee,{force:!0}]],S=()=>J?c(G.value):f(G,ae,!0),z=(e,t)=>{t=t||1;var n=ee.nextStringDelay;oe.insert(e,[V,n.before]),oe.insert(e+t+1,[V,n.after])},O=E((function(){if(ae){var e="[data-typeit-id='".concat(ie,"'] .ti-cursor");return y("@keyframes blink-".concat(ie," { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } ").concat(e," { animation: blink-").concat(ie," ").concat(ee.cursorSpeed/1e3,"s infinite; } ").concat(e,".with-delay { animation-delay: 500ms; } ").concat(e,".disabled { animation: none; }"),ie),G.appendChild(ae),w(document.fonts.ready,(function(){var e=ae.getBoundingClientRect().width/2;ae.style.margin="0 -".concat(e+1,"px 0 -").concat(e-1,"px")}))}})),B=e=>{ae&&(ae.classList.toggle("disabled",e),ae.classList.toggle("with-delay",!e))},q=E((function(e,t){return X.push(setTimeout(e,t)),w()})),I=E((function(e){return C((function(){if(Z)return H(j(Z))}),(function(){oe.reset().delete(0).add([V,e.before],!0),S().forEach(e=>{oe.add([Q,null,{isPhantom:!0}],1,!0)})}))})),R=E((function(){_.started=!0;var e=oe.getItems();return k(function(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}((function(){return k(function(e,t,n){var r,i,o=-1;return function a(u){try{for(;++o<e.length&&(!n||!n());)if((u=t(o))&&u.then){if(!((c=u)instanceof P&&1&c.s))return void u.then(a,i||(i=A.bind(null,r=new P,2)));u=u.v}r?A(r,1,u):r=u}catch(e){A(r||(r=new P),2,e)}var c}(),r}(e,(function(t){if(_.frozen||_.destroyed)throw"";var n,r,i,a,u=e[t],c=u[2],s=[u,o];return c.freezeCursor&&B(!0),n=ee.speed,r=ee.deleteSpeed,i=ee.lifeLike,a=(r=null!==r?r:n/3)/2,W=i?[b(n,n/2),b(r,a)]:[n,r],C((function(){var e;if(null==c?void 0:c.isFirst)return H((e=ee).beforeString.apply(e,s))}),(function(){var e;return w((e=ee).beforeStep.apply(e,s),(function(){return w(u[0].call(o,u[1],c),(function(){return C((function(){if(!c||!c.isPhantom)return C((function(){var e,t;if(null===(e=u[2])||void 0===e?void 0:e.isLast)return H((t=ee).afterString.apply(t,s))}),(function(){var e;return w((e=ee).afterStep.apply(e,s),(function(){u[2].executed=!0}))}))}),(function(){B(!1)}))}))}))}))}),(function(){return!1})),(function(e){return _.completed=!0,w(ee.afterComplete(o),(function(){if(ee.loop){var e=ee.loopDelay;q((function(){return w(I(e),(function(){R()}))}),e.after)}}))}))}),D),(function(e){return o}))})),V=e=>new Promise(t=>{q(()=>t(),e||0)}),j=e=>{var t=S(),n=x(e,Z,t);return Z+=n.numberOfSteps,new Promise(e=>{q(E((function(){return((e,t,n,r)=>{if(n){var i=r,o=t[(i=i>t.length?t.length:i)-1];(e=o?o.parentNode:e).insertBefore(n,o||null)}})(G,S(),ae,Z),C((function(){if(n.isString&&n.canKeepMoving)return H(j(n.numberOfSteps>0?"START":"END"))}),(function(){return e()}))})),W[0])})},U=e=>new Promise(t=>{q(()=>(T(G,e,ae,Z),t()),W[0])}),F=E((function(e){ee=n(ee,e)})),K=E((function(){J?G.value="":S().forEach(e=>{L(e)})})),Q=e=>(e=!0===e,new Promise(t=>{q(E((function(){var n=!1,r=S();return r.length&&(J?G.value=G.value.slice(0,-1):L(r[Z])),c(G.querySelectorAll("*")).forEach(e=>{if(!e.innerHTML){for(var t=e;1===t.parentNode.childNodes.length&&t.parentNode.childNodes[0].isEqualNode(t);)t=t.parentNode;L(t)}}),C((function(){if(e&&r.length-1>0)return w(Q(!0),(function(){return n=!0,t()}))}),(function(e){return n?e:t()}))})),W[1])}));this.break=function(e){return s([U,h(m("BR"))],1,e)},this.delete=function(e,t){var n=d(t);return s([n[0]].concat([].concat(Array(e||1)).map(()=>[Q,!e,$]),[n[1]]),1,t)},this.empty=function(){return s(K,1,arguments)},this.exec=function(e,t){var n=d(t);return s([n[0],[e,null],n[1]],1,t)},this.move=function(e,t){var n=x(e,Z,S()),r=d(t),i=n.isString?e:Math.sign(e);return s([r[0]].concat([].concat(Array(Math.abs(e)||1)).map(()=>[j,i,$]),[r[1]]),1,t)},this.options=function(e){return s([F,e],1,e)},this.pause=function(e,t){return s([V,e],1,t)},this.type=function(e,t){var n=d(t),r=v(e,ee.html),i=[n[0]].concat(a(r,U,$,!0),[n[1]]);return s(i,1,t)},this.is=function(e){return _[e]},this.destroy=function(e){e=void 0===e||e,X.forEach(e=>{clearTimeout(e)}),X=[],e&&L(ae),_.destroyed=!0},this.freeze=function(){_.frozen=!0},this.unfreeze=function(){_.frozen=!1,!_.frozen&&R()},this.reset=function(){for(var e in!this.is("destroyed")&&this.destroy(),oe.reset(),_)_[e]=!1;return this},this.go=function(){return _.started?this:(O(),ee.waitUntilVisible?(((e,t)=>{new IntersectionObserver((n,r)=>{n.forEach(n=>{n.isIntersecting&&(t(),r.unobserve(e))})},{threshold:1}).observe(e)})(G,R.bind(this)),this):(R(),this))},this.getQueue=function(){return oe},this.getOptions=function(){return ee},this.getElement=function(){return G};var Y,G="string"==typeof(Y=t)?document.querySelector(Y):Y,J=N(G),W=[],X=[],Z=0,$={freezeCursor:!0},_={started:!1,completed:!1,frozen:!1,destroyed:!1},ee=n(e,i);ee=n(ee,{html:!J&&ee.html,nextStringDelay:g(ee.nextStringDelay),loopDelay:g(ee.loopDelay)});var te,ne,re,ie=Math.random().toString().substring(2,9),oe=new u([V,ee.startDelay]);G.setAttribute("data-typeit-id",ie),y("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}[data-typeit-id]"),ee.strings=(re=ee.strings,te=r(re)?re:[re],(ne=(e=>e.innerHTML.replace(/<\!--.*?-->/g,"").trim())(G))?(G.innerHTML="",ee.startDelete?(p(ne).forEach(e=>{T(G,e,ae,Z)}),oe.add([Q,!0]),z(1),te):[ne.trim()].concat(te)):te);var ae=(()=>{if(J||!ee.cursor)return null;var e=m("span");return e.innerHTML=l(ee.cursorChar).innerHTML,e.className="ti-cursor",e.style.cssText="display:inline;".concat(M(G)),e})();ee.strings.length&&(()=>{var e=ee.strings;e.forEach((t,n)=>{var r=v(t,ee.html);oe.add(a(r,U,$,!0));var i=oe.getItems().length;if(n+1!==e.length){if(ee.breakLines){var o=h(m("BR"));return oe.add([U,o,$]),void z(i)}oe.add(a(r,Q,$)),z(i,t.length)}})})()} | ||
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:()=>{},afterString:()=>{},beforeStep:()=>{},afterStep:()=>{},afterComplete:()=>{}},t=e=>e.map(e=>(void 0===e[1]&&e.push(null),void 0===e[2]&&e.push({}),e)),n=(e,t)=>Object.assign({},e,t),r=e=>Array.isArray(e),i=(e,t)=>(e[2]=n(e[2],t)||t,e),o=(e,t)=>r(e[0])?e.map(e=>i(e,t)):i(e,t),a=(e,t,n,i)=>{i=i||!1,n=n||{};var a=!r(e),u=e.length;return(e=a?new Array(e).fill(0):e).map((e,r)=>{if(a)return t;var c=[t,e,n];return i&&(0===r&&(c=o(c,{isFirst:!0})),r+1===u&&(c=o(c,{isLast:!0}))),c})};function u(e){this.insert=function(e,t){i.splice(e,0,t)},this.add=function(e,u,c){return e=r(e)?e:[e,null],c=c||!1,u=u||1,r(e[0])||(e=a(u,e)),e=t(e).map(e=>(e[2]=n(e[2],{id:o}),o++,e)),i=c?e.concat(i):i.concat(e),this},this.delete=function(e){return i.splice(e,1),this},this.reset=function(){return i=i.map(e=>(e[2].executed=!1,e)),this},this.getItems=function(){return(i=t(i)).filter(e=>!e[2].executed)},this.setMeta=function(e,t){var r=i.findIndex(t=>t[2].id===e);i[r][2]=n(i[r][2],t)};var i=[],o=0;this.add(e)}var c=e=>Array.from(e),s=e=>{var t=[];return t.concat.apply(t,e)},l=e=>{var t=document.implementation.createHTMLDocument("");return t.body.innerHTML=e,t.body},f=(e,t,n)=>{t=t||null,n=void 0!==n&&n;var r=c(e.childNodes).map(e=>{return 3===(t=e).nodeType||"BR"===t.tagName?e:f(e);var t});return r=s(r),t&&(r=r.filter(e=>!e.parentNode.isEqualNode(t))),n?r.reverse():r},d=e=>"BODY"===e.tagName,h=(e,t)=>{t=t||null;var n=e instanceof HTMLElement;return{node:t,isTopLevelText:(!t||d(t.parentNode))&&!n,isHTMLElement:n,content:e}};function v(e){var t,n=l(e);return t=f(n).map(e=>e.nodeValue?c(e.nodeValue).map(t=>h(t,e)):h(e)),s(t)}function p(e,t){return(t=void 0===t||t)?v(e):c(e).map(e=>h(e))}var m=e=>document.createElement(e),y=(e,t)=>{var n=m("style");n.id=t||"",n.appendChild(document.createTextNode(e)),document.head.appendChild(n)},g=e=>(r(e)||(e=[e/2,e/2]),{before:e[0],after:e[1],total:e[0]+e[1]}),b=(e,t)=>Math.abs(Math.random()*(e+t-(e-t))+(e-t));var N=e=>["textarea","input"].indexOf(e.tagName.toLowerCase())>-1,S=(e,t)=>{var n=t.querySelectorAll("*");return[t].concat(c(n).reverse()).find(t=>t.cloneNode().outerHTML===e.outerHTML)},T=(e,t,n,r)=>{n=n||null;var i=t.isHTMLElement,o=i?t.content:document.createTextNode(t.content);if(N(e))e.value="".concat(e.value).concat(t.content);else{if(!t.isTopLevelText&&!i){var a=t.node.parentNode,u=S(a.cloneNode(),e);if(((e,t)=>{if(!e)return!1;var n=e.nextSibling;return!n||n.isEqualNode(t)})(u,n))e=u;else if((o=a.cloneNode()).innerText=t.content,!d(a.parentNode)){for(var c=a.parentNode,s=c.cloneNode(),l=S(s,e);!l&&!d(c);)s.innerHTML=o.outerHTML,o=s,s=c.parentNode.cloneNode(),c=c.parentNode,l=S(s,e);e=l||e}}var h=f(e,n,!0)[r-1],v=h?h.parentNode:e;v.insertBefore(o,v.contains(n)?n:null)}},L=e=>{var t;return null==e||null===(t=e.parentNode)||void 0===t?void 0:t.removeChild(e)};var M=(e,t,n)=>{var r,i="string"==typeof e,o=!1,a=-1*e;return i&&(a=(r="END"===e.toUpperCase())?-1:1,o=r?t+a>0:t+a<n.length),{isString:i,numberOfSteps:a,canKeepMoving:o}},x=e=>{var t,n=["font","lineHeight","color"],r=m("SPAN"),i=(t=e,window.getComputedStyle(t,null));for(var o in i)n.indexOf(o)>-1&&i[o]&&(r.style[o]=i[o]);return r.style.cssText};function w(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function E(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{return Promise.resolve(e.apply(this,t))}catch(e){return Promise.reject(e)}}}function D(){}function H(e,t){if(!t)return e&&e.then?e.then(D):Promise.resolve()}function C(e,t){var n=e();return n&&n.then?n.then(t):t(n)}function A(e,t,n){if(!e.s){if(n instanceof P){if(!n.s)return void(n.o=A.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(A.bind(null,e,t),A.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var P=function(){function e(){}return e.prototype.then=function(t,n){var r=new e,i=this.s;if(i){var o=1&i?t:n;if(o){try{A(r,1,o(this.v))}catch(e){A(r,2,e)}return r}return this}return this.o=function(e){try{var i=e.v;1&e.s?A(r,1,t?t(i):i):n?A(r,1,n(i)):A(r,2,i)}catch(e){A(r,2,e)}},r},e}();function k(e,t){return e&&e.then?e.then(t):t(e)}export default function(t,i){var o=this;i=i||{};var s=(e,t,n)=>(e=r(e[0])?e:[e],oe.add(e,t),(e=>{var t=(e=e||{}).delay;t&&oe.add([V,t])})(n),this),d=e=>[[F,e="object"==typeof e?e:{},{force:!0}],[F,ee,{force:!0}]],S=()=>J?c(G.value):f(G,ae,!0),O=(e,t)=>{t=t||1;var n=ee.nextStringDelay;oe.insert(e,[V,n.before]),oe.insert(e+t+1,[V,n.after])},z=E((function(){if(ae){var e="[data-typeit-id='".concat(ie,"'] .ti-cursor");y("@keyframes blink-".concat(ie," { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } ").concat(e," { animation: blink-").concat(ie," ").concat(ee.cursorSpeed/1e3,"s infinite; } ").concat(e,".with-delay { animation-delay: 500ms; } ").concat(e,".disabled { animation: none; }"),ie),G.appendChild(ae);var t="loaded"===document.fonts.status;return w(t||document.fonts.ready,(function(e){var t=ae.getBoundingClientRect().width/2;ae.style.margin="0 -".concat(t+2,"px 0 -").concat(t-2,"px")}),t)}})),B=e=>{ae&&(ae.classList.toggle("disabled",e),ae.classList.toggle("with-delay",!e))},q=E((function(e,t){return X.push(setTimeout(e,t)),w()})),I=E((function(e){return C((function(){if(Z)return H(j(Z))}),(function(){oe.reset().delete(0).add([V,e.before],!0),S().forEach(e=>{oe.add([Q,null,{isPhantom:!0}],1,!0)})}))})),R=E((function(){_.started=!0;var e,t=oe.getItems();return k(function(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}((function(){return k(function(e,t,n){var r,i,o=-1;return function a(u){try{for(;++o<e.length&&(!n||!n());)if((u=t(o))&&u.then){if(!((c=u)instanceof P&&1&c.s))return void u.then(a,i||(i=A.bind(null,r=new P,2)));u=u.v}r?A(r,1,u):r=u}catch(e){A(r||(r=new P),2,e)}var c}(),r}(t,(function(n){if(_.frozen||_.destroyed)throw"";var r,i,a,u,c=t[n],s=c[2];return e=[c,o],s.freezeCursor&&B(!0),r=ee.speed,i=ee.deleteSpeed,a=ee.lifeLike,u=(i=null!==i?i:r/3)/2,W=a?[b(r,r/2),b(i,u)]:[r,i],C((function(){var t;if(null==s?void 0:s.isFirst)return H((t=ee).beforeString.apply(t,e))}),(function(){var t;return w((t=ee).beforeStep.apply(t,e),(function(){return w(c[0].call(o,c[1],s),(function(){return C((function(){if(!s||!s.isPhantom)return C((function(){var t,n;if(null===(t=c[2])||void 0===t?void 0:t.isLast)return H((n=ee).afterString.apply(n,e))}),(function(){var t;return w((t=ee).afterStep.apply(t,e),(function(){oe.setMeta(s.id,{executed:!0})}))}))}),(function(){B(!1)}))}))}))}))}),(function(){return!1})),(function(t){var n;return _.completed=!0,w((n=ee).afterComplete.apply(n,e),(function(){if(ee.loop){var e=ee.loopDelay;q((function(){return w(I(e),(function(){R()}))}),e.after)}}))}))}),D),(function(e){return o}))})),V=e=>new Promise(t=>{q(()=>t(),e||0)}),j=e=>{var t=S(),n=M(e,Z,t);return Z+=n.numberOfSteps,new Promise(e=>{q(E((function(){return((e,t,n,r)=>{if(n){var i=r,o=t[(i=i>t.length?t.length:i)-1];(e=o?o.parentNode:e).insertBefore(n,o||null)}})(G,S(),ae,Z),C((function(){if(n.isString&&n.canKeepMoving)return H(j(n.numberOfSteps>0?"START":"END"))}),(function(){return e()}))})),W[0])})},U=e=>new Promise(t=>{q(()=>(T(G,e,ae,Z),t()),W[0])}),F=E((function(e){ee=n(ee,e)})),K=E((function(){J?G.value="":S().forEach(e=>{L(e)})})),Q=e=>(e=!0===e,new Promise(t=>{q(E((function(){var n=!1,r=S();return r.length&&(J?G.value=G.value.slice(0,-1):L(r[Z])),c(G.querySelectorAll("*")).forEach(e=>{if(!e.innerHTML){for(var t=e;1===t.parentNode.childNodes.length&&t.parentNode.childNodes[0].isEqualNode(t);)t=t.parentNode;L(t)}}),C((function(){if(e&&r.length-1>0)return w(Q(!0),(function(){return n=!0,t()}))}),(function(e){return n?e:t()}))})),W[1])}));this.break=function(e){return s([U,h(m("BR"))],1,e)},this.delete=function(e,t){var n=d(t);return s([n[0]].concat([].concat(Array(Math.abs(e)||1)).fill().map(()=>[Q,!e,$]),[n[1]]),1,t)},this.empty=function(){return s(K,1,arguments)},this.exec=function(e,t){var n=d(t);return s([n[0],[e,null],n[1]],1,t)},this.move=function(e,t){var n=M(e,Z,S()),r=d(t),i=n.isString?e:Math.sign(e);return s([r[0]].concat([].concat(Array(Math.abs(e)||1)).fill().map(()=>[j,i,$]),[r[1]]),1,t)},this.options=function(e){return s([F,e],1,e)},this.pause=function(e,t){return s([V,e],1,t)},this.type=function(e,t){var n=d(t),r=p(e,ee.html),i=[n[0]].concat(a(r,U,$,!0),[n[1]]);return s(i,1,t)},this.is=function(e){return _[e]},this.destroy=function(e){e=void 0===e||e,X.forEach(e=>{clearTimeout(e)}),X=[],e&&L(ae),_.destroyed=!0},this.freeze=function(){_.frozen=!0},this.unfreeze=function(){_.frozen=!1,R()},this.reset=function(){for(var e in!this.is("destroyed")&&this.destroy(),oe.reset(),Z=0,_)_[e]=!1;return J?G.value="":G.innerHTML="",this},this.go=function(){return _.started?this:(z(),ee.waitUntilVisible?(((e,t)=>{new IntersectionObserver((n,r)=>{n.forEach(n=>{n.isIntersecting&&(t(),r.unobserve(e))})},{threshold:1}).observe(e)})(G,R.bind(this)),this):(R(),this))},this.getQueue=function(){return oe},this.getOptions=function(){return ee},this.getElement=function(){return G};var Y,G="string"==typeof(Y=t)?document.querySelector(Y):Y,J=N(G),W=[],X=[],Z=0,$={freezeCursor:!0},_={started:!1,completed:!1,frozen:!1,destroyed:!1},ee=n(e,i);ee=n(ee,{html:!J&&ee.html,nextStringDelay:g(ee.nextStringDelay),loopDelay:g(ee.loopDelay)});var te,ne,re,ie=Math.random().toString().substring(2,9),oe=new u([V,ee.startDelay]);G.setAttribute("data-typeit-id",ie),y("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}[data-typeit-id]"),ee.strings=(re=ee.strings,te=r(re)?re:[re],(ne=(e=>e.innerHTML.replace(/<\!--.*?-->/g,"").trim())(G))?(G.innerHTML="",ee.startDelete?(v(ne).forEach(e=>{T(G,e,ae,Z)}),oe.add([Q,!0]),O(1),te):[ne.trim()].concat(te)):te);var ae=(()=>{if(J||!ee.cursor)return null;var e=m("span");return e.innerHTML=l(ee.cursorChar).innerHTML,e.className="ti-cursor",e.style.cssText="display:inline;".concat(x(G)),e})();ee.strings.length&&(()=>{var e=ee.strings;e.forEach((t,n)=>{var r=p(t,ee.html);oe.add(a(r,U,$,!0));var i=oe.getItems().length;if(n+1!==e.length){if(ee.breakLines){var o=h(m("BR"));return oe.add([U,o,$]),void O(i)}oe.add(a(r,Q,$)),O(i,t.length)}})})()} |
/** | ||
* TypeIt - The most versatile animated typing utility on the planet. | ||
* Author: Alex MacArthur <alex@macarthur.me> (https://macarthur.me) | ||
* Version: v7.0.0-rc9 | ||
* Version: v7.0.0 | ||
* License: GPL-2.0 | ||
* URL: https://typeitjs.com | ||
*/ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n=n||self).TypeIt=t()}(this,(function(){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(t)}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:function(){},afterString:function(){},beforeStep:function(){},afterStep:function(){},afterComplete:function(){}},e=function(n){return n.map((function(n){return void 0===n[1]&&n.push(null),void 0===n[2]&&n.push({}),n}))},r=function(n,t){return Object.assign({},n,t)},i=function(n){return Array.isArray(n)},o=function(n,t){return n[2]=r(n[2],t)||t,n},u=function(n,t){return i(n[0])?n.map((function(n){return o(n,t)})):o(n,t)},c=function(n,t,e,r){r=r||!1,e=e||{};var o=!i(n),c=n.length;return(n=o?new Array(n).fill(0):n).map((function(n,i){if(o)return t;var a=[t,n,e];return r&&(0===i&&(a=u(a,{isFirst:!0})),i+1===c&&(a=u(a,{isLast:!0}))),a}))};function a(n){this.insert=function(n,e){t.splice(n,0,e)},this.add=function(n,e,r){return n=i(n)?n:[n,null],r=r||!1,e=e||1,i(n[0])||(n=c(e,n)),t=r?n.concat(t):t.concat(n),this},this.delete=function(n){return t.splice(n,1),this},this.reset=function(){return t=e(t).map((function(n){return n[2].executed=!1,n})),this},this.getItems=function(){return e(t).filter((function(n){return!n.executed}))};var t=[];n&&this.add(n)}var f=function(n){return Array.from(n)},s=function(n){var t=[];return t.concat.apply(t,n)},l=function(n){var t=document.implementation.createHTMLDocument("");return t.body.innerHTML=n,t.body},d=function n(t,e,r){e=e||null,r=void 0!==r&&r;var i=f(t.childNodes).map((function(t){return 3===(e=t).nodeType||"BR"===e.tagName?t:n(t);var e}));return i=s(i),e&&(i=i.filter((function(n){return!n.parentNode.isEqualNode(e)}))),r?i.reverse():i},h=function(n){return"BODY"===n.tagName},p=function(n,t){t=t||null;var e=n instanceof HTMLElement;return{node:t,isTopLevelText:(!t||h(t.parentNode))&&!e,isHTMLElement:e,content:n}};function v(n){var t,e=l(n);return t=d(e).map((function(n){return n.nodeValue?f(n.nodeValue).map((function(t){return p(t,n)})):p(n)})),s(t)}function y(n,t){return(t=void 0===t||t)?v(n):f(n).map((function(n){return p(n)}))}var m=function(n){return document.createElement(n)},g=function(n,t){var e=m("style");e.id=t||"",e.appendChild(document.createTextNode(n)),document.head.appendChild(e)},b=function(n){return i(n)||(n=[n/2,n/2]),{before:n[0],after:n[1],total:n[0]+n[1]}},S=function(n,t){return Math.abs(Math.random()*(n+t-(n-t))+(n-t))};var N=function(n){return["textarea","input"].indexOf(n.tagName.toLowerCase())>-1},T=function(n,t){var e=t.querySelectorAll("*");return[t].concat(f(e).reverse()).find((function(t){return t.cloneNode().outerHTML===n.outerHTML}))},L=function(n,t,e,r){e=e||null;var i=t.isHTMLElement,o=i?t.content:document.createTextNode(t.content);if(N(n))n.value="".concat(n.value).concat(t.content);else{if(!t.isTopLevelText&&!i){var u=t.node.parentNode,c=T(u.cloneNode(),n);if(function(n,t){if(!n)return!1;var e=n.nextSibling;return!e||e.isEqualNode(t)}(c,e))n=c;else if((o=u.cloneNode()).innerText=t.content,!h(u.parentNode)){for(var a=u.parentNode,f=a.cloneNode(),s=T(f,n);!s&&!h(a);)f.innerHTML=o.outerHTML,o=f,f=a.parentNode.cloneNode(),a=a.parentNode,s=T(f,n);n=s||n}}var l=d(n,e,!0)[r-1],p=l?l.parentNode:n;p.insertBefore(o,p.contains(e)?e:null)}},x=function(n){return n&&n.parentNode.removeChild(n)};var M=function(n,t,e){var r,i="string"==typeof n,o=!1,u=-1*n;return i&&(u=(r="END"===n.toUpperCase())?-1:1,o=r?t+u>0:t+u<e.length),{isString:i,numberOfSteps:u,canKeepMoving:o}},w=function(n){var t,e=["font","lineHeight","color"],r=m("SPAN"),i=(t=n,window.getComputedStyle(t,null));for(var o in i)e.indexOf(o)>-1&&i[o]&&(r.style[o]=i[o]);return r.style.cssText};function E(n,t,e){return e?t?t(n):n:(n&&n.then||(n=Promise.resolve(n)),t?n.then(t):n)}function D(n){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{return Promise.resolve(n.apply(this,t))}catch(n){return Promise.reject(n)}}}function H(){}function C(n,t){if(!t)return n&&n.then?n.then(H):Promise.resolve()}function A(n,t){var e=n();return e&&e.then?e.then(t):t(e)}function P(n,t,e){if(!n.s){if(e instanceof k){if(!e.s)return void(e.o=P.bind(null,n,t));1&t&&(t=e.s),e=e.v}if(e&&e.then)return void e.then(P.bind(null,n,t),P.bind(null,n,2));n.s=t,n.v=e;var r=n.o;r&&r(n)}}var k=function(){function n(){}return n.prototype.then=function(t,e){var r=new n,i=this.s;if(i){var o=1&i?t:e;if(o){try{P(r,1,o(this.v))}catch(n){P(r,2,n)}return r}return this}return this.o=function(n){try{var i=n.v;1&n.s?P(r,1,t?t(i):i):e?P(r,1,e(i)):P(r,2,i)}catch(n){P(r,2,n)}},r},n}();function z(n,t){return n&&n.then?n.then(t):t(n)}return function(e,o){var u=this,s=this;o=o||{};var h=function(n,t,e){return n=i(n[0])?n:[n],an.add(n,t),function(n){var t=(n=n||{}).delay;t&&an.add([U,t])}(e),s},T=function(t){return t="object"===n(t)?t:{},[[Q,t,{force:!0}],[Q,en,{force:!0}]]},O=function(){return X?f(W.value):d(W,fn,!0)},B=function(n,t){t=t||1;var e=en.nextStringDelay;an.insert(n,[U,e.before]),an.insert(n+t+1,[U,e.after])},q=D((function(){if(fn){var n="[data-typeit-id='".concat(cn,"'] .ti-cursor");return g("@keyframes blink-".concat(cn," { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } ").concat(n," { animation: blink-").concat(cn," ").concat(en.cursorSpeed/1e3,"s infinite; } ").concat(n,".with-delay { animation-delay: 500ms; } ").concat(n,".disabled { animation: none; }"),cn),W.appendChild(fn),E(document.fonts.ready,(function(){var n=fn.getBoundingClientRect().width/2;fn.style.margin="0 -".concat(n+1,"px 0 -").concat(n-1,"px")}))}})),I=function(n){fn&&(fn.classList.toggle("disabled",n),fn.classList.toggle("with-delay",!n))},R=D((function(n,t){return $.push(setTimeout(n,t)),E()})),j=D((function(n){return A((function(){if(_)return C(F(_))}),(function(){an.reset().delete(0).add([U,n.before],!0),O().forEach((function(n){an.add([G,null,{isPhantom:!0}],1,!0)}))}))})),V=D((function(){tn.started=!0;var n=an.getItems();return z(function(n,t){try{var e=n()}catch(n){return t(n)}return e&&e.then?e.then(void 0,t):e}((function(){return z(function(n,t,e){var r,i,o=-1;return function u(c){try{for(;++o<n.length&&(!e||!e());)if((c=t(o))&&c.then){if(!((a=c)instanceof k&&1&a.s))return void c.then(u,i||(i=P.bind(null,r=new k,2)));c=c.v}r?P(r,1,c):r=c}catch(n){P(r||(r=new k),2,n)}var a}(),r}(n,(function(t){if(tn.frozen||tn.destroyed)throw"";var e,r,i,o,c=n[t],a=c[2],f=[c,u];return a.freezeCursor&&I(!0),e=en.speed,r=en.deleteSpeed,i=en.lifeLike,o=(r=null!==r?r:e/3)/2,Z=i?[S(e,e/2),S(r,o)]:[e,r],A((function(){var n;if(null==a?void 0:a.isFirst)return C((n=en).beforeString.apply(n,f))}),(function(){var n;return E((n=en).beforeStep.apply(n,f),(function(){return E(c[0].call(u,c[1],a),(function(){return A((function(){if(!a||!a.isPhantom)return A((function(){var n,t;if(null===(n=c[2])||void 0===n?void 0:n.isLast)return C((t=en).afterString.apply(t,f))}),(function(){var n;return E((n=en).afterStep.apply(n,f),(function(){c[2].executed=!0}))}))}),(function(){I(!1)}))}))}))}))}),(function(){return!1})),(function(n){return tn.completed=!0,E(en.afterComplete(u),(function(){if(en.loop){var n=en.loopDelay;R((function(){return E(j(n),(function(){V()}))}),n.after)}}))}))}),H),(function(n){return u}))})),U=function(n){return new Promise((function(t){R((function(){return t()}),n||0)}))},F=function n(t){var e=O(),r=M(t,_,e);return _+=r.numberOfSteps,new Promise((function(t){R(D((function(){return function(n,t,e,r){if(e){var i=r,o=t[(i=i>t.length?t.length:i)-1];(n=o?o.parentNode:n).insertBefore(e,o||null)}}(W,O(),fn,_),A((function(){if(r.isString&&r.canKeepMoving)return C(n(r.numberOfSteps>0?"START":"END"))}),(function(){return t()}))})),Z[0])}))},K=function(n){return new Promise((function(t){R((function(){return L(W,n,fn,_),t()}),Z[0])}))},Q=D((function(n){en=r(en,n)})),Y=D((function(){X?W.value="":O().forEach((function(n){x(n)}))})),G=function n(t){return t=!0===t,new Promise((function(e){R(D((function(){var r=!1,i=O();return i.length&&(X?W.value=W.value.slice(0,-1):x(i[_])),f(W.querySelectorAll("*")).forEach((function(n){if(!n.innerHTML){for(var t=n;1===t.parentNode.childNodes.length&&t.parentNode.childNodes[0].isEqualNode(t);)t=t.parentNode;x(t)}})),A((function(){if(t&&i.length-1>0)return E(n(!0),(function(){return r=!0,e()}))}),(function(n){return r?n:e()}))})),Z[1])}))};this.break=function(n){return h([K,p(m("BR"))],1,n)},this.delete=function(n,t){var e=T(t);return h([e[0]].concat([].concat(Array(n||1)).map((function(){return[G,!n,nn]})),[e[1]]),1,t)},this.empty=function(){return h(Y,1,arguments)},this.exec=function(n,t){var e=T(t);return h([e[0],[n,null],e[1]],1,t)},this.move=function(n,t){var e=M(n,_,O()),r=T(t),i=e.isString?n:Math.sign(n);return h([r[0]].concat([].concat(Array(Math.abs(n)||1)).map((function(){return[F,i,nn]})),[r[1]]),1,t)},this.options=function(n){return h([Q,n],1,n)},this.pause=function(n,t){return h([U,n],1,t)},this.type=function(n,t){var e=T(t),r=y(n,en.html),i=[e[0]].concat(c(r,K,nn,!0),[e[1]]);return h(i,1,t)},this.is=function(n){return tn[n]},this.destroy=function(n){n=void 0===n||n,$.forEach((function(n){clearTimeout(n)})),$=[],n&&x(fn),tn.destroyed=!0},this.freeze=function(){tn.frozen=!0},this.unfreeze=function(){tn.frozen=!1,!tn.frozen&&V()},this.reset=function(){for(var n in!this.is("destroyed")&&this.destroy(),an.reset(),tn)tn[n]=!1;return this},this.go=function(){return tn.started?this:(q(),en.waitUntilVisible?(function(n,t){new IntersectionObserver((function(e,r){e.forEach((function(e){e.isIntersecting&&(t(),r.unobserve(n))}))}),{threshold:1}).observe(n)}(W,V.bind(this)),this):(V(),this))},this.getQueue=function(){return an},this.getOptions=function(){return en},this.getElement=function(){return W};var J,W="string"==typeof(J=e)?document.querySelector(J):J,X=N(W),Z=[],$=[],_=0,nn={freezeCursor:!0},tn={started:!1,completed:!1,frozen:!1,destroyed:!1},en=r(t,o);en=r(en,{html:!X&&en.html,nextStringDelay:b(en.nextStringDelay),loopDelay:b(en.loopDelay)});var rn,on,un,cn=Math.random().toString().substring(2,9),an=new a([U,en.startDelay]);W.setAttribute("data-typeit-id",cn),g("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}[data-typeit-id]"),en.strings=(un=en.strings,rn=i(un)?un:[un],(on=function(n){return n.innerHTML.replace(/<\!--.*?-->/g,"").trim()}(W))?(W.innerHTML="",en.startDelete?(v(on).forEach((function(n){L(W,n,fn,_)})),an.add([G,!0]),B(1),rn):[on.trim()].concat(rn)):rn);var fn=function(){if(X||!en.cursor)return null;var n=m("span");return n.innerHTML=l(en.cursorChar).innerHTML,n.className="ti-cursor",n.style.cssText="display:inline;".concat(w(W)),n}();en.strings.length&&function(){var n=en.strings;n.forEach((function(t,e){var r=y(t,en.html);an.add(c(r,K,nn,!0));var i=an.getItems().length;if(e+1!==n.length){if(en.breakLines){var o=p(m("BR"));return an.add([K,o,nn]),void B(i)}an.add(c(r,G,nn)),B(i,t.length)}}))}()}})); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n=n||self).TypeIt=t()}(this,(function(){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(t)}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:function(){},afterString:function(){},beforeStep:function(){},afterStep:function(){},afterComplete:function(){}},e=function(n){return n.map((function(n){return void 0===n[1]&&n.push(null),void 0===n[2]&&n.push({}),n}))},r=function(n,t){return Object.assign({},n,t)},i=function(n){return Array.isArray(n)},o=function(n,t){return n[2]=r(n[2],t)||t,n},u=function(n,t){return i(n[0])?n.map((function(n){return o(n,t)})):o(n,t)},c=function(n,t,e,r){r=r||!1,e=e||{};var o=!i(n),c=n.length;return(n=o?new Array(n).fill(0):n).map((function(n,i){if(o)return t;var a=[t,n,e];return r&&(0===i&&(a=u(a,{isFirst:!0})),i+1===c&&(a=u(a,{isLast:!0}))),a}))};function a(n){this.insert=function(n,e){t.splice(n,0,e)},this.add=function(n,u,a){return n=i(n)?n:[n,null],a=a||!1,u=u||1,i(n[0])||(n=c(u,n)),n=e(n).map((function(n){return n[2]=r(n[2],{id:o}),o++,n})),t=a?n.concat(t):t.concat(n),this},this.delete=function(n){return t.splice(n,1),this},this.reset=function(){return t=t.map((function(n){return n[2].executed=!1,n})),this},this.getItems=function(){return(t=e(t)).filter((function(n){return!n[2].executed}))},this.setMeta=function(n,e){var i=t.findIndex((function(t){return t[2].id===n}));t[i][2]=r(t[i][2],e)};var t=[],o=0;this.add(n)}var f=function(n){return Array.from(n)},s=function(n){var t=[];return t.concat.apply(t,n)},l=function(n){var t=document.implementation.createHTMLDocument("");return t.body.innerHTML=n,t.body},d=function n(t,e,r){e=e||null,r=void 0!==r&&r;var i=f(t.childNodes).map((function(t){return 3===(e=t).nodeType||"BR"===e.tagName?t:n(t);var e}));return i=s(i),e&&(i=i.filter((function(n){return!n.parentNode.isEqualNode(e)}))),r?i.reverse():i},h=function(n){return"BODY"===n.tagName},p=function(n,t){t=t||null;var e=n instanceof HTMLElement;return{node:t,isTopLevelText:(!t||h(t.parentNode))&&!e,isHTMLElement:e,content:n}};function v(n){var t,e=l(n);return t=d(e).map((function(n){return n.nodeValue?f(n.nodeValue).map((function(t){return p(t,n)})):p(n)})),s(t)}function y(n,t){return(t=void 0===t||t)?v(n):f(n).map((function(n){return p(n)}))}var m=function(n){return document.createElement(n)},g=function(n,t){var e=m("style");e.id=t||"",e.appendChild(document.createTextNode(n)),document.head.appendChild(e)},b=function(n){return i(n)||(n=[n/2,n/2]),{before:n[0],after:n[1],total:n[0]+n[1]}},S=function(n,t){return Math.abs(Math.random()*(n+t-(n-t))+(n-t))};var N=function(n){return["textarea","input"].indexOf(n.tagName.toLowerCase())>-1},T=function(n,t){var e=t.querySelectorAll("*");return[t].concat(f(e).reverse()).find((function(t){return t.cloneNode().outerHTML===n.outerHTML}))},L=function(n,t,e,r){e=e||null;var i=t.isHTMLElement,o=i?t.content:document.createTextNode(t.content);if(N(n))n.value="".concat(n.value).concat(t.content);else{if(!t.isTopLevelText&&!i){var u=t.node.parentNode,c=T(u.cloneNode(),n);if(function(n,t){if(!n)return!1;var e=n.nextSibling;return!e||e.isEqualNode(t)}(c,e))n=c;else if((o=u.cloneNode()).innerText=t.content,!h(u.parentNode)){for(var a=u.parentNode,f=a.cloneNode(),s=T(f,n);!s&&!h(a);)f.innerHTML=o.outerHTML,o=f,f=a.parentNode.cloneNode(),a=a.parentNode,s=T(f,n);n=s||n}}var l=d(n,e,!0)[r-1],p=l?l.parentNode:n;p.insertBefore(o,p.contains(e)?e:null)}},M=function(n){var t;return null==n||null===(t=n.parentNode)||void 0===t?void 0:t.removeChild(n)};var x=function(n,t,e){var r,i="string"==typeof n,o=!1,u=-1*n;return i&&(u=(r="END"===n.toUpperCase())?-1:1,o=r?t+u>0:t+u<e.length),{isString:i,numberOfSteps:u,canKeepMoving:o}},w=function(n){var t,e=["font","lineHeight","color"],r=m("SPAN"),i=(t=n,window.getComputedStyle(t,null));for(var o in i)e.indexOf(o)>-1&&i[o]&&(r.style[o]=i[o]);return r.style.cssText};function E(n,t,e){return e?t?t(n):n:(n&&n.then||(n=Promise.resolve(n)),t?n.then(t):n)}function D(n){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{return Promise.resolve(n.apply(this,t))}catch(n){return Promise.reject(n)}}}function H(){}function C(n,t){if(!t)return n&&n.then?n.then(H):Promise.resolve()}function A(n,t){var e=n();return e&&e.then?e.then(t):t(e)}function P(n,t,e){if(!n.s){if(e instanceof k){if(!e.s)return void(e.o=P.bind(null,n,t));1&t&&(t=e.s),e=e.v}if(e&&e.then)return void e.then(P.bind(null,n,t),P.bind(null,n,2));n.s=t,n.v=e;var r=n.o;r&&r(n)}}var k=function(){function n(){}return n.prototype.then=function(t,e){var r=new n,i=this.s;if(i){var o=1&i?t:e;if(o){try{P(r,1,o(this.v))}catch(n){P(r,2,n)}return r}return this}return this.o=function(n){try{var i=n.v;1&n.s?P(r,1,t?t(i):i):e?P(r,1,e(i)):P(r,2,i)}catch(n){P(r,2,n)}},r},n}();function O(n,t){return n&&n.then?n.then(t):t(n)}return function(e,o){var u=this,s=this;o=o||{};var h=function(n,t,e){return n=i(n[0])?n:[n],an.add(n,t),function(n){var t=(n=n||{}).delay;t&&an.add([U,t])}(e),s},T=function(t){return t="object"===n(t)?t:{},[[Q,t,{force:!0}],[Q,en,{force:!0}]]},z=function(){return X?f(W.value):d(W,fn,!0)},B=function(n,t){t=t||1;var e=en.nextStringDelay;an.insert(n,[U,e.before]),an.insert(n+t+1,[U,e.after])},I=D((function(){if(fn){var n="[data-typeit-id='".concat(cn,"'] .ti-cursor");g("@keyframes blink-".concat(cn," { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } ").concat(n," { animation: blink-").concat(cn," ").concat(en.cursorSpeed/1e3,"s infinite; } ").concat(n,".with-delay { animation-delay: 500ms; } ").concat(n,".disabled { animation: none; }"),cn),W.appendChild(fn);var t="loaded"===document.fonts.status;return E(t||document.fonts.ready,(function(n){var t=fn.getBoundingClientRect().width/2;fn.style.margin="0 -".concat(t+2,"px 0 -").concat(t-2,"px")}),t)}})),q=function(n){fn&&(fn.classList.toggle("disabled",n),fn.classList.toggle("with-delay",!n))},R=D((function(n,t){return $.push(setTimeout(n,t)),E()})),j=D((function(n){return A((function(){if(_)return C(F(_))}),(function(){an.reset().delete(0).add([U,n.before],!0),z().forEach((function(n){an.add([G,null,{isPhantom:!0}],1,!0)}))}))})),V=D((function(){tn.started=!0;var n,t=an.getItems();return O(function(n,t){try{var e=n()}catch(n){return t(n)}return e&&e.then?e.then(void 0,t):e}((function(){return O(function(n,t,e){var r,i,o=-1;return function u(c){try{for(;++o<n.length&&(!e||!e());)if((c=t(o))&&c.then){if(!((a=c)instanceof k&&1&a.s))return void c.then(u,i||(i=P.bind(null,r=new k,2)));c=c.v}r?P(r,1,c):r=c}catch(n){P(r||(r=new k),2,n)}var a}(),r}(t,(function(e){if(tn.frozen||tn.destroyed)throw"";var r,i,o,c,a=t[e],f=a[2];return n=[a,u],f.freezeCursor&&q(!0),r=en.speed,i=en.deleteSpeed,o=en.lifeLike,c=(i=null!==i?i:r/3)/2,Z=o?[S(r,r/2),S(i,c)]:[r,i],A((function(){var t;if(null==f?void 0:f.isFirst)return C((t=en).beforeString.apply(t,n))}),(function(){var t;return E((t=en).beforeStep.apply(t,n),(function(){return E(a[0].call(u,a[1],f),(function(){return A((function(){if(!f||!f.isPhantom)return A((function(){var t,e;if(null===(t=a[2])||void 0===t?void 0:t.isLast)return C((e=en).afterString.apply(e,n))}),(function(){var t;return E((t=en).afterStep.apply(t,n),(function(){an.setMeta(f.id,{executed:!0})}))}))}),(function(){q(!1)}))}))}))}))}),(function(){return!1})),(function(t){var e;return tn.completed=!0,E((e=en).afterComplete.apply(e,n),(function(){if(en.loop){var n=en.loopDelay;R((function(){return E(j(n),(function(){V()}))}),n.after)}}))}))}),H),(function(n){return u}))})),U=function(n){return new Promise((function(t){R((function(){return t()}),n||0)}))},F=function n(t){var e=z(),r=x(t,_,e);return _+=r.numberOfSteps,new Promise((function(t){R(D((function(){return function(n,t,e,r){if(e){var i=r,o=t[(i=i>t.length?t.length:i)-1];(n=o?o.parentNode:n).insertBefore(e,o||null)}}(W,z(),fn,_),A((function(){if(r.isString&&r.canKeepMoving)return C(n(r.numberOfSteps>0?"START":"END"))}),(function(){return t()}))})),Z[0])}))},K=function(n){return new Promise((function(t){R((function(){return L(W,n,fn,_),t()}),Z[0])}))},Q=D((function(n){en=r(en,n)})),Y=D((function(){X?W.value="":z().forEach((function(n){M(n)}))})),G=function n(t){return t=!0===t,new Promise((function(e){R(D((function(){var r=!1,i=z();return i.length&&(X?W.value=W.value.slice(0,-1):M(i[_])),f(W.querySelectorAll("*")).forEach((function(n){if(!n.innerHTML){for(var t=n;1===t.parentNode.childNodes.length&&t.parentNode.childNodes[0].isEqualNode(t);)t=t.parentNode;M(t)}})),A((function(){if(t&&i.length-1>0)return E(n(!0),(function(){return r=!0,e()}))}),(function(n){return r?n:e()}))})),Z[1])}))};this.break=function(n){return h([K,p(m("BR"))],1,n)},this.delete=function(n,t){var e=T(t);return h([e[0]].concat([].concat(Array(Math.abs(n)||1)).fill().map((function(){return[G,!n,nn]})),[e[1]]),1,t)},this.empty=function(){return h(Y,1,arguments)},this.exec=function(n,t){var e=T(t);return h([e[0],[n,null],e[1]],1,t)},this.move=function(n,t){var e=x(n,_,z()),r=T(t),i=e.isString?n:Math.sign(n);return h([r[0]].concat([].concat(Array(Math.abs(n)||1)).fill().map((function(){return[F,i,nn]})),[r[1]]),1,t)},this.options=function(n){return h([Q,n],1,n)},this.pause=function(n,t){return h([U,n],1,t)},this.type=function(n,t){var e=T(t),r=y(n,en.html),i=[e[0]].concat(c(r,K,nn,!0),[e[1]]);return h(i,1,t)},this.is=function(n){return tn[n]},this.destroy=function(n){n=void 0===n||n,$.forEach((function(n){clearTimeout(n)})),$=[],n&&M(fn),tn.destroyed=!0},this.freeze=function(){tn.frozen=!0},this.unfreeze=function(){tn.frozen=!1,V()},this.reset=function(){for(var n in!this.is("destroyed")&&this.destroy(),an.reset(),_=0,tn)tn[n]=!1;return X?W.value="":W.innerHTML="",this},this.go=function(){return tn.started?this:(I(),en.waitUntilVisible?(function(n,t){new IntersectionObserver((function(e,r){e.forEach((function(e){e.isIntersecting&&(t(),r.unobserve(n))}))}),{threshold:1}).observe(n)}(W,V.bind(this)),this):(V(),this))},this.getQueue=function(){return an},this.getOptions=function(){return en},this.getElement=function(){return W};var J,W="string"==typeof(J=e)?document.querySelector(J):J,X=N(W),Z=[],$=[],_=0,nn={freezeCursor:!0},tn={started:!1,completed:!1,frozen:!1,destroyed:!1},en=r(t,o);en=r(en,{html:!X&&en.html,nextStringDelay:b(en.nextStringDelay),loopDelay:b(en.loopDelay)});var rn,on,un,cn=Math.random().toString().substring(2,9),an=new a([U,en.startDelay]);W.setAttribute("data-typeit-id",cn),g("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}[data-typeit-id]"),en.strings=(un=en.strings,rn=i(un)?un:[un],(on=function(n){return n.innerHTML.replace(/<\!--.*?-->/g,"").trim()}(W))?(W.innerHTML="",en.startDelete?(v(on).forEach((function(n){L(W,n,fn,_)})),an.add([G,!0]),B(1),rn):[on.trim()].concat(rn)):rn);var fn=function(){if(X||!en.cursor)return null;var n=m("span");return n.innerHTML=l(en.cursorChar).innerHTML,n.className="ti-cursor",n.style.cssText="display:inline;".concat(w(W)),n}();en.strings.length&&function(){var n=en.strings;n.forEach((function(t,e){var r=y(t,en.html);an.add(c(r,K,nn,!0));var i=an.getItems().length;if(e+1!==n.length){if(en.breakLines){var o=p(m("BR"));return an.add([K,o,nn]),void B(i)}an.add(c(r,G,nn)),B(i,t.length)}}))}()}})); |
{ | ||
"name": "typeit", | ||
"version": "7.0.0-rc9", | ||
"version": "7.0.0", | ||
"description": "The most versatile animated typing utility on the planet.", | ||
@@ -5,0 +5,0 @@ "author": "Alex MacArthur <alex@macarthur.me> (https://macarthur.me)", |
@@ -11,3 +11,3 @@ # TypeIt | ||
<p align="center"> | ||
<img src="demo.gif" alt="" style="border: 5px solid #24292e;"> | ||
<img src="readme-demo.gif" alt="" style="border: 5px solid #24292e;"> | ||
</p> | ||
@@ -51,19 +51,2 @@ | ||
## Browser Support | ||
There are two bundles generated -- an ES module version for [browsers that support them](https://caniuse.com/#feat=es6-module), and a fully transpiled bundle. When in doubt, go for the latter. If you're using IE11 or older, you'll also need the following polyfills: | ||
- `Array.prototype.fill` | ||
- `Array.prototype.find` | ||
- `Array.from` | ||
- `IntersectionObserver` | ||
- `Object.assign` | ||
- `Promise` | ||
You can load all of these yourself, or just use the following pre-made bundle from [Polyfill.io](https://polyfill.io): | ||
```html | ||
<script src="https://polyfill.io/v3/polyfill.min.js?features=Array.prototype.fill%2CIntersectionObserver%2CObject.assign%2CPromise%2CArray.from%2CArray.prototype.find"></script> | ||
``` | ||
## Contribute | ||
@@ -70,0 +53,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
106
0
52697
65