Comparing version 7.0.0-rc5 to 7.0.0-rc6
/** | ||
* TypeIt - The most versatile animated typing utility on the planet. | ||
* Author: Alex MacArthur <alex@macarthur.me> (https://macarthur.me) | ||
* Version: v7.0.0-rc5 | ||
* Version: v7.0.0-rc6 | ||
* 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 s=[t,e,n];return i&&(0===r&&(s=o(s,{isFirst:!0})),r+1===u&&(s=o(s,{isLast:!0}))),s})};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 s=e=>Array.from(e),c=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=>3===e.nodeType||"BR"===e.tagName,d=(e,t,n)=>{t=t||null,n=void 0!==n&&n;var r=s(e.childNodes).map(e=>f(e)?e:d(e));return r=c(r),t&&(r=r.filter(e=>!e.parentNode.isEqualNode(t))),n?r.reverse():r},h=e=>"BODY"===e.tagName,v=(e,t)=>{t=t||null;var n=e instanceof HTMLElement;return{node:t,isTopLevelText:(!t||h(t.parentNode))&&!n,isHTMLElement:n,content:e}};function p(e){var t,n=l(e);return t=d(n).map(e=>e.nodeValue?s(e.nodeValue).map(t=>v(t,e)):v(e)),c(t)}function m(e,t){return(t=void 0===t||t)?p(e):s(e).map(e=>v(e))}var y=e=>document.createElement(e),g=(e,t)=>{var n=y("style");n.id=t||"",n.appendChild(document.createTextNode(e)),document.head.appendChild(n)},b=e=>(r(e)||(e=[e/2,e/2]),{before:e[0],after:e[1],total:e[0]+e[1]}),S=(e,t)=>Math.abs(Math.random()*(e+t-(e-t))+(e-t));var N=e=>["textarea","input"].indexOf(e.tagName.toLowerCase())>-1,T=(e,t)=>{var n=t.querySelectorAll("*");return[t].concat(s(n).reverse()).find(t=>t.cloneNode().outerHTML===e.outerHTML)},L=(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=T(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,!h(a.parentNode)){for(var s=a.parentNode,c=s.cloneNode(),l=T(c,e);!l&&!h(s);)c.innerHTML=o.outerHTML,o=c,c=s.parentNode.cloneNode(),s=s.parentNode,l=T(c,e);e=l||e}}var f=d(e,n,!0)[r-1],v=f?f.parentNode:e;v.insertBefore(o,v.contains(n)?n:null)}},x=e=>e&&e.parentNode.removeChild(e),M=e=>!e.firstChild&&!f(e),w=e=>e.some(e=>M(e));var D=(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}};function E(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function C(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 H(){}function P(e,t){if(!t)return e&&e.then?e.then(H):Promise.resolve()}function A(e,t){var n=e();return n&&n.then?n.then(t):t(n)}function k(e,t,n){if(!e.s){if(n instanceof z){if(!n.s)return void(n.o=k.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(k.bind(null,e,t),k.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var z=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{k(r,1,o(this.v))}catch(e){k(r,2,e)}return r}return this}return this.o=function(e){try{var i=e.v;1&e.s?k(r,1,t?t(i):i):n?k(r,1,n(i)):k(r,2,i)}catch(e){k(r,2,e)}},r},e}();function O(e,t){return e&&e.then?e.then(t):t(e)}export default function(t,i){var o=this;i=i||{};var c=(e,t)=>(oe.add(e,t),this),f=e=>{e=e||{};var t=n({},ee),r=n(t,e);return[[F,r,{force:!0}],[F,t,{force:!0}]]},h=()=>J?s(G.value):d(G,ae,!0),T=(e,t)=>{t=t||1;var n=ee.nextStringDelay;oe.insert(e,[V,n.before]),oe.insert(e+t+1,[V,n.after])},q=e=>{ae&&(ae.classList.toggle("disabled",e),ae.classList.toggle("with-delay",!e))},B=C((function(e,t){return X.push(setTimeout(e,t)),E()})),I=C((function(e){return A((function(){if(Z)return P(move(-1*Z))}),(function(){oe.reset().delete(0).add([V,e.before],!0),h().forEach(e=>{oe.add([Q,null,{isPhantom:!0}],1,!0)})}))})),R=C((function(){_.started=!0;var e=oe.getItems();return O(function(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}((function(){return O(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(!((s=u)instanceof z&&1&s.s))return void u.then(a,i||(i=k.bind(null,r=new z,2)));u=u.v}r?k(r,1,u):r=u}catch(e){k(r||(r=new z),2,e)}var s}(),r}(e,(function(t){if(_.frozen||_.destroyed)throw"";var n,r,i,a,u=e[t],s=u[2],c=[u,o];return s.freezeCursor&&q(!0),n=ee.speed,r=ee.deleteSpeed,i=ee.lifeLike,a=(r=null!==r?r:n/3)/2,W=i?[S(n,n/2),S(r,a)]:[n,r],A((function(){var e;if(null==s?void 0:s.isFirst)return P((e=ee).beforeString.apply(e,c))}),(function(){var e;return E((e=ee).beforeStep.apply(e,c),(function(){return E(u[0].call(o,u[1],s),(function(){return A((function(){if(!s||!s.isPhantom)return A((function(){var e,t;if(null===(e=u[2])||void 0===e?void 0:e.isLast)return P((t=ee).afterString.apply(t,c))}),(function(){var e;return E((e=ee).afterStep.apply(e,c),(function(){u[2].executed=!0}))}))}),(function(){q(!1)}))}))}))}))}),(function(){return!1})),(function(e){return _.completed=!0,E(ee.afterComplete(o),(function(){if(ee.loop){var e=ee.loopDelay||ee.nextStringDelay;B((function(){return E(I(e),(function(){R()}))}),e.after)}}))}))}),H),(function(e){return o}))})),V=e=>new Promise(t=>{B(()=>t(),e||ee.nextStringDelay.total)}),U=e=>{var t=h(),n=D(e,Z,t);return Z+=n.numberOfSteps,new Promise(e=>{B(C((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,h(),ae,Z),A((function(){if(n.isString&&n.canKeepMoving)return P(U(n.numberOfSteps>0?"START":"END"))}),(function(){return e()}))})),W[0])})},j=e=>new Promise(t=>{B(()=>(L(G,e,ae,Z),t()),W[0])}),F=C((function(e){ee=n(ee,e)})),K=C((function(){J?G.value="":h().forEach(e=>{x(e)})})),Q=e=>(e=!0===e,new Promise(t=>{B(C((function(){var n=!1,r=h();return r.length&&(J?G.value=G.value.slice(0,-1):x(r[Z])),(e=>{for(var t=s(e.querySelectorAll("*")),n=w(t);t.length&&n;){var r=!1;t.forEach(e=>{M(e)&&(x(e),r=!0)}),r&&(t=s(e.querySelectorAll("*"))),n=w(t)}})(G),A((function(){if(e&&r.length-1>0)return E(Q(!0),(function(){return n=!0,t()}))}),(function(e){return n?e:t()}))})),W[1])}));this.break=function(){return c([j,v(y("BR"))])},this.delete=function(e,t){var n=f(t);return oe.add(n[0]),oe.add([Q,!e,$],e||1),oe.add(n[1]),this},this.destroy=function(e){e=void 0===e||e,X.forEach(e=>{clearTimeout(e)}),X=[],e&&x(ae),_.destroyed=!0},this.empty=function(){return c(K)},this.exec=function(e,t){var n=f(t);return c([n[0],[e,null],n[1]])},this.is=function(e){return _[e]},this.move=function(e,t){var n=D(e,Z,h()),r=f(t);return oe.add(r[0]),oe.add([U,n.isString?e:Math.sign(e),$],Math.abs(e)),oe.add(r[1]),this},this.freeze=function(){_.frozen=!0},this.unfreeze=function(){_.frozen=!1,!_.frozen&&R()},this.options=function(e){return c([F,e])},this.pause=function(e){return c([V,e||null])},this.type=function(e,t){var n=f(t),r=m(e,ee.html),i=[n[0]].concat(a(r,j,$,!0),[n[1]]);return c(i)},this.getQueue=function(){return oe},this.getOptions=function(){return ee},this.getElement=function(){return G},this.reset=function(){for(var e in!this.is("destroyed")&&this.destroy(),oe.reset(),_)_[e]=!1;return this},this.go=function(){return _.started?this:((()=>{if(ae){var e="[data-typeit-id='".concat(ie,"'] .ti-cursor");g("@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)}})(),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))};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:b(ee.nextStringDelay),loopDelay:b(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),g("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}"),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=>{L(G,e,ae,Z)}),oe.add([Q,!0]),T(1),te):[ne.trim()].concat(te)):te);var ae=(()=>{if(J||!ee.cursor)return null;var e=y("span");return e.innerHTML=l(ee.cursorChar).innerHTML,e.className="ti-cursor",e.style.cssText="position:absolute;display:inline;margin-left:-.025em;".concat((e=>{var t=["font","lineHeight","color"],n=y("SPAN"),r=window.getComputedStyle(e,null);for(var i in r)t.indexOf(i)>-1&&r[i]&&(n.style[i]=r[i]);return n.style.cssText})(G)),e})();ee.strings.length&&(()=>{var e=ee.strings;e.forEach((t,n)=>{var r=m(t,ee.html);oe.add(a(r,j,$,!0));var i=oe.getItems().length;if(n+1!==e.length){if(ee.breakLines){var o=v(y("BR"));return oe.add([j,o,$]),void T(i)}oe.add(a(r,Q,$)),T(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 s=[t,e,n];return i&&(0===r&&(s=o(s,{isFirst:!0})),r+1===u&&(s=o(s,{isLast:!0}))),s})};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 s=e=>Array.from(e),c=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=>3===e.nodeType||"BR"===e.tagName,d=(e,t,n)=>{t=t||null,n=void 0!==n&&n;var r=s(e.childNodes).map(e=>f(e)?e:d(e));return r=c(r),t&&(r=r.filter(e=>!e.parentNode.isEqualNode(t))),n?r.reverse():r},h=e=>"BODY"===e.tagName,v=(e,t)=>{t=t||null;var n=e instanceof HTMLElement;return{node:t,isTopLevelText:(!t||h(t.parentNode))&&!n,isHTMLElement:n,content:e}};function p(e){var t,n=l(e);return t=d(n).map(e=>e.nodeValue?s(e.nodeValue).map(t=>v(t,e)):v(e)),c(t)}function m(e,t){return(t=void 0===t||t)?p(e):s(e).map(e=>v(e))}var y=e=>document.createElement(e),g=(e,t)=>{var n=y("style");n.id=t||"",n.appendChild(document.createTextNode(e)),document.head.appendChild(n)},b=e=>(r(e)||(e=[e/2,e/2]),{before:e[0],after:e[1],total:e[0]+e[1]}),S=(e,t)=>Math.abs(Math.random()*(e+t-(e-t))+(e-t));var T=e=>["textarea","input"].indexOf(e.tagName.toLowerCase())>-1,N=(e,t)=>{var n=t.querySelectorAll("*");return[t].concat(s(n).reverse()).find(t=>t.cloneNode().outerHTML===e.outerHTML)},x=(e,t,n,r)=>{n=n||null;var i=t.isHTMLElement,o=i?t.content:document.createTextNode(t.content);if(T(e))e.value="".concat(e.value).concat(t.content);else{if(!t.isTopLevelText&&!i){var a=t.node.parentNode,u=N(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,!h(a.parentNode)){for(var s=a.parentNode,c=s.cloneNode(),l=N(c,e);!l&&!h(s);)c.innerHTML=o.outerHTML,o=c,c=s.parentNode.cloneNode(),s=s.parentNode,l=N(c,e);e=l||e}}var f=d(e,n,!0)[r-1],v=f?f.parentNode:e;v.insertBefore(o,v.contains(n)?n:null)}},L=e=>e&&e.parentNode.removeChild(e),w=e=>!e.firstChild&&!f(e),M=e=>e.some(e=>w(e));var D=(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}},C=e=>window.getComputedStyle(e,null);function E(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function H(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 P(){}function z(e,t){if(!t)return e&&e.then?e.then(P):Promise.resolve()}function A(e,t){var n=e();return n&&n.then?n.then(t):t(n)}function k(e,t,n){if(!e.s){if(n instanceof O){if(!n.s)return void(n.o=k.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(k.bind(null,e,t),k.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var O=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{k(r,1,o(this.v))}catch(e){k(r,2,e)}return r}return this}return this.o=function(e){try{var i=e.v;1&e.s?k(r,1,t?t(i):i):n?k(r,1,n(i)):k(r,2,i)}catch(e){k(r,2,e)}},r},e}();function B(e,t){return e&&e.then?e.then(t):t(e)}export default function(t,i){var o=this;i=i||{};var c=(e,t)=>(ue.add(e,t),this),f=e=>{e=e||{};var t=n({},ne),r=n(t,e);return[[Q,r,{force:!0}],[Q,t,{force:!0}]]},h=()=>X?s(W.value):d(W,se,!0),N=(e,t)=>{t=t||1;var n=ne.nextStringDelay;ue.insert(e,[j,n.before]),ue.insert(e+t+1,[j,n.after])},q=()=>{if(se){var e="[data-typeit-id='".concat(ae,"'] .ti-cursor");g("@keyframes blink-".concat(ae," { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } ").concat(e," { animation: blink-").concat(ae," ").concat(ne.cursorSpeed/1e3,"s infinite; } ").concat(e,".with-delay { animation-delay: 500ms; } ").concat(e,".disabled { animation: none; }"),ae),W.appendChild(se);var t,n,r=se.getBoundingClientRect().width-(t=se,(n=y("canvas").getContext("2d")).font=C(t).getPropertyValue("font-size"),n.measureText(t.innerText).width);se.style.margin="0 -".concat(r,"px")}},I=e=>{se&&(se.classList.toggle("disabled",e),se.classList.toggle("with-delay",!e))},R=H((function(e,t){return $.push(setTimeout(e,t)),E()})),V=H((function(e){return A((function(){if(_)return z(move(-1*_))}),(function(){ue.reset().delete(0).add([j,e.before],!0),h().forEach(e=>{ue.add([G,null,{isPhantom:!0}],1,!0)})}))})),U=H((function(){te.started=!0;var e=ue.getItems();return B(function(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}((function(){return B(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(!((s=u)instanceof O&&1&s.s))return void u.then(a,i||(i=k.bind(null,r=new O,2)));u=u.v}r?k(r,1,u):r=u}catch(e){k(r||(r=new O),2,e)}var s}(),r}(e,(function(t){if(te.frozen||te.destroyed)throw"";var n,r,i,a,u=e[t],s=u[2],c=[u,o];return s.freezeCursor&&I(!0),n=ne.speed,r=ne.deleteSpeed,i=ne.lifeLike,a=(r=null!==r?r:n/3)/2,Z=i?[S(n,n/2),S(r,a)]:[n,r],A((function(){var e;if(null==s?void 0:s.isFirst)return z((e=ne).beforeString.apply(e,c))}),(function(){var e;return E((e=ne).beforeStep.apply(e,c),(function(){return E(u[0].call(o,u[1],s),(function(){return A((function(){if(!s||!s.isPhantom)return A((function(){var e,t;if(null===(e=u[2])||void 0===e?void 0:e.isLast)return z((t=ne).afterString.apply(t,c))}),(function(){var e;return E((e=ne).afterStep.apply(e,c),(function(){u[2].executed=!0}))}))}),(function(){I(!1)}))}))}))}))}),(function(){return!1})),(function(e){return te.completed=!0,E(ne.afterComplete(o),(function(){if(ne.loop){var e=ne.loopDelay||ne.nextStringDelay;R((function(){return E(V(e),(function(){U()}))}),e.after)}}))}))}),P),(function(e){return o}))})),j=e=>new Promise(t=>{R(()=>t(),e||ne.nextStringDelay.total)}),F=e=>{var t=h(),n=D(e,_,t);return _+=n.numberOfSteps,new Promise(e=>{R(H((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)}})(W,h(),se,_),A((function(){if(n.isString&&n.canKeepMoving)return z(F(n.numberOfSteps>0?"START":"END"))}),(function(){return e()}))})),Z[0])})},K=e=>new Promise(t=>{R(()=>(x(W,e,se,_),t()),Z[0])}),Q=H((function(e){ne=n(ne,e)})),Y=H((function(){X?W.value="":h().forEach(e=>{L(e)})})),G=e=>(e=!0===e,new Promise(t=>{R(H((function(){var n=!1,r=h();return r.length&&(X?W.value=W.value.slice(0,-1):L(r[_])),(e=>{for(var t=s(e.querySelectorAll("*")),n=M(t);t.length&&n;){var r=!1;t.forEach(e=>{w(e)&&(L(e),r=!0)}),r&&(t=s(e.querySelectorAll("*"))),n=M(t)}})(W),A((function(){if(e&&r.length-1>0)return E(G(!0),(function(){return n=!0,t()}))}),(function(e){return n?e:t()}))})),Z[1])}));this.break=function(){return c([K,v(y("BR"))])},this.delete=function(e,t){var n=f(t);return ue.add(n[0]),ue.add([G,!e,ee],e||1),ue.add(n[1]),this},this.destroy=function(e){e=void 0===e||e,$.forEach(e=>{clearTimeout(e)}),$=[],e&&L(se),te.destroyed=!0},this.empty=function(){return c(Y)},this.exec=function(e,t){var n=f(t);return c([n[0],[e,null],n[1]])},this.is=function(e){return te[e]},this.move=function(e,t){var n=D(e,_,h()),r=f(t);return ue.add(r[0]),ue.add([F,n.isString?e:Math.sign(e),ee],Math.abs(e)),ue.add(r[1]),this},this.freeze=function(){te.frozen=!0},this.unfreeze=function(){te.frozen=!1,!te.frozen&&U()},this.options=function(e){return c([Q,e])},this.pause=function(e){return c([j,e||null])},this.type=function(e,t){var n=f(t),r=m(e,ne.html),i=[n[0]].concat(a(r,K,ee,!0),[n[1]]);return c(i)},this.getQueue=function(){return ue},this.getOptions=function(){return ne},this.getElement=function(){return W},this.reset=function(){for(var e in!this.is("destroyed")&&this.destroy(),ue.reset(),te)te[e]=!1;return this},this.go=function(){return te.started?this:(q(),ne.waitUntilVisible?(((e,t)=>{new IntersectionObserver((n,r)=>{n.forEach(n=>{n.isIntersecting&&(t(),r.unobserve(e))})},{threshold:1}).observe(e)})(W,U.bind(this)),this):(U(),this))};var J,W="string"==typeof(J=t)?document.querySelector(J):J,X=T(W),Z=[],$=[],_=0,ee={freezeCursor:!0},te={started:!1,completed:!1,frozen:!1,destroyed:!1},ne=n(e,i);ne=n(ne,{html:!X&&ne.html,nextStringDelay:b(ne.nextStringDelay),loopDelay:b(ne.loopDelay)});var re,ie,oe,ae=Math.random().toString().substring(2,9),ue=new u([j,ne.startDelay]);W.setAttribute("data-typeit-id",ae),g("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}"),ne.strings=(oe=ne.strings,re=r(oe)?oe:[oe],(ie=(e=>e.innerHTML.replace(/<\!--.*?-->/g,"").trim())(W))?(W.innerHTML="",ne.startDelete?(p(ie).forEach(e=>{x(W,e,se,_)}),ue.add([G,!0]),N(1),re):[ie.trim()].concat(re)):re);var se=(()=>{if(X||!ne.cursor)return null;var e=y("span");return e.innerHTML=l(ne.cursorChar).innerHTML,e.className="ti-cursor",e.style.cssText="display:inline;".concat((e=>{var t=["font","lineHeight","color"],n=y("SPAN"),r=C(e);for(var i in r)t.indexOf(i)>-1&&r[i]&&(n.style[i]=r[i]);return n.style.cssText})(W)),e})();ne.strings.length&&(()=>{var e=ne.strings;e.forEach((t,n)=>{var r=m(t,ne.html);ue.add(a(r,K,ee,!0));var i=ue.getItems().length;if(n+1!==e.length){if(ne.breakLines){var o=v(y("BR"));return ue.add([K,o,ee]),void N(i)}ue.add(a(r,G,ee)),N(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-rc5 | ||
* Version: v7.0.0-rc6 | ||
* 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";var n={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(){}},t=function(n){return n.map((function(n){return void 0===n[1]&&n.push(null),void 0===n[2]&&n.push({}),n}))},e=function(n,t){return Object.assign({},n,t)},r=function(n){return Array.isArray(n)},i=function(n,t){return n[2]=e(n[2],t)||t,n},o=function(n,t){return r(n[0])?n.map((function(n){return i(n,t)})):i(n,t)},u=function(n,t,e,i){i=i||!1,e=e||{};var u=!r(n),c=n.length;return(n=u?new Array(n).fill(0):n).map((function(n,r){if(u)return t;var a=[t,n,e];return i&&(0===r&&(a=o(a,{isFirst:!0})),r+1===c&&(a=o(a,{isLast:!0}))),a}))};function c(n){this.insert=function(n,t){e.splice(n,0,t)},this.add=function(n,t,i){return n=r(n)?n:[n,null],i=i||!1,t=t||1,r(n[0])||(n=u(t,n)),e=i?n.concat(e):e.concat(n),this},this.delete=function(n){return e.splice(n,1),this},this.reset=function(){return e=t(e).map((function(n){return n[2].executed=!1,n})),this},this.getItems=function(){return t(e).filter((function(n){return!n.executed}))};var e=[];n&&this.add(n)}var a=function(n){return Array.from(n)},f=function(n){var t=[];return t.concat.apply(t,n)},s=function(n){var t=document.implementation.createHTMLDocument("");return t.body.innerHTML=n,t.body},l=function(n){return 3===n.nodeType||"BR"===n.tagName},d=function n(t,e,r){e=e||null,r=void 0!==r&&r;var i=a(t.childNodes).map((function(t){return l(t)?t:n(t)}));return i=f(i),e&&(i=i.filter((function(n){return!n.parentNode.isEqualNode(e)}))),r?i.reverse():i},h=function(n){return"BODY"===n.tagName},v=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 p(n){var t,e=s(n);return t=d(e).map((function(n){return n.nodeValue?a(n.nodeValue).map((function(t){return v(t,n)})):v(n)})),f(t)}function m(n,t){return(t=void 0===t||t)?p(n):a(n).map((function(n){return v(n)}))}var y=function(n){return document.createElement(n)},g=function(n,t){var e=y("style");e.id=t||"",e.appendChild(document.createTextNode(n)),document.head.appendChild(e)},b=function(n){return r(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 T=function(n){return["textarea","input"].indexOf(n.tagName.toLowerCase())>-1},N=function(n,t){var e=t.querySelectorAll("*");return[t].concat(a(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(T(n))n.value="".concat(n.value).concat(t.content);else{if(!t.isTopLevelText&&!i){var u=t.node.parentNode,c=N(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=N(f,n);!s&&!h(a);)f.innerHTML=o.outerHTML,o=f,f=a.parentNode.cloneNode(),a=a.parentNode,s=N(f,n);n=s||n}}var l=d(n,e,!0)[r-1],v=l?l.parentNode:n;v.insertBefore(o,v.contains(e)?e:null)}},x=function(n){return n&&n.parentNode.removeChild(n)},M=function(n){return!n.firstChild&&!l(n)},w=function(n){return n.some((function(n){return M(n)}))};var D=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}};function E(n,t,e){return e?t?t(n):n:(n&&n.then||(n=Promise.resolve(n)),t?n.then(t):n)}function C(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 P(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 k(n,t,e){if(!n.s){if(e instanceof z){if(!e.s)return void(e.o=k.bind(null,n,t));1&t&&(t=e.s),e=e.v}if(e&&e.then)return void e.then(k.bind(null,n,t),k.bind(null,n,2));n.s=t,n.v=e;var r=n.o;r&&r(n)}}var z=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{k(r,1,o(this.v))}catch(n){k(r,2,n)}return r}return this}return this.o=function(n){try{var i=n.v;1&n.s?k(r,1,t?t(i):i):e?k(r,1,e(i)):k(r,2,i)}catch(n){k(r,2,n)}},r},n}();function O(n,t){return n&&n.then?n.then(t):t(n)}return function(t,i){var o=this,f=this;i=i||{};var l=function(n,t){return cn.add(n,t),f},h=function(n){n=n||{};var t=e({},tn),r=e(t,n);return[[K,r,{force:!0}],[K,t,{force:!0}]]},N=function(){return W?a(J.value):d(J,an,!0)},q=function(n,t){t=t||1;var e=tn.nextStringDelay;cn.insert(n,[j,e.before]),cn.insert(n+t+1,[j,e.after])},B=function(n){an&&(an.classList.toggle("disabled",n),an.classList.toggle("with-delay",!n))},I=C((function(n,t){return Z.push(setTimeout(n,t)),E()})),R=C((function(n){return A((function(){if($)return P(move(-1*$))}),(function(){cn.reset().delete(0).add([j,n.before],!0),N().forEach((function(n){cn.add([Y,null,{isPhantom:!0}],1,!0)}))}))})),V=C((function(){nn.started=!0;var n=cn.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 z&&1&a.s))return void c.then(u,i||(i=k.bind(null,r=new z,2)));c=c.v}r?k(r,1,c):r=c}catch(n){k(r||(r=new z),2,n)}var a}(),r}(n,(function(t){if(nn.frozen||nn.destroyed)throw"";var e,r,i,u,c=n[t],a=c[2],f=[c,o];return a.freezeCursor&&B(!0),e=tn.speed,r=tn.deleteSpeed,i=tn.lifeLike,u=(r=null!==r?r:e/3)/2,X=i?[S(e,e/2),S(r,u)]:[e,r],A((function(){var n;if(null==a?void 0:a.isFirst)return P((n=tn).beforeString.apply(n,f))}),(function(){var n;return E((n=tn).beforeStep.apply(n,f),(function(){return E(c[0].call(o,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 P((t=tn).afterString.apply(t,f))}),(function(){var n;return E((n=tn).afterStep.apply(n,f),(function(){c[2].executed=!0}))}))}),(function(){B(!1)}))}))}))}))}),(function(){return!1})),(function(n){return nn.completed=!0,E(tn.afterComplete(o),(function(){if(tn.loop){var n=tn.loopDelay||tn.nextStringDelay;I((function(){return E(R(n),(function(){V()}))}),n.after)}}))}))}),H),(function(n){return o}))})),j=function(n){return new Promise((function(t){I((function(){return t()}),n||tn.nextStringDelay.total)}))},U=function n(t){var e=N(),r=D(t,$,e);return $+=r.numberOfSteps,new Promise((function(t){I(C((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)}}(J,N(),an,$),A((function(){if(r.isString&&r.canKeepMoving)return P(n(r.numberOfSteps>0?"START":"END"))}),(function(){return t()}))})),X[0])}))},F=function(n){return new Promise((function(t){I((function(){return L(J,n,an,$),t()}),X[0])}))},K=C((function(n){tn=e(tn,n)})),Q=C((function(){W?J.value="":N().forEach((function(n){x(n)}))})),Y=function n(t){return t=!0===t,new Promise((function(e){I(C((function(){var r=!1,i=N();return i.length&&(W?J.value=J.value.slice(0,-1):x(i[$])),function(n){for(var t=a(n.querySelectorAll("*")),e=w(t);t.length&&e;){var r=!1;t.forEach((function(n){M(n)&&(x(n),r=!0)})),r&&(t=a(n.querySelectorAll("*"))),e=w(t)}}(J),A((function(){if(t&&i.length-1>0)return E(n(!0),(function(){return r=!0,e()}))}),(function(n){return r?n:e()}))})),X[1])}))};this.break=function(){return l([F,v(y("BR"))])},this.delete=function(n,t){var e=h(t);return cn.add(e[0]),cn.add([Y,!n,_],n||1),cn.add(e[1]),this},this.destroy=function(n){n=void 0===n||n,Z.forEach((function(n){clearTimeout(n)})),Z=[],n&&x(an),nn.destroyed=!0},this.empty=function(){return l(Q)},this.exec=function(n,t){var e=h(t);return l([e[0],[n,null],e[1]])},this.is=function(n){return nn[n]},this.move=function(n,t){var e=D(n,$,N()),r=h(t);return cn.add(r[0]),cn.add([U,e.isString?n:Math.sign(n),_],Math.abs(n)),cn.add(r[1]),this},this.freeze=function(){nn.frozen=!0},this.unfreeze=function(){nn.frozen=!1,!nn.frozen&&V()},this.options=function(n){return l([K,n])},this.pause=function(n){return l([j,n||null])},this.type=function(n,t){var e=h(t),r=m(n,tn.html),i=[e[0]].concat(u(r,F,_,!0),[e[1]]);return l(i)},this.getQueue=function(){return cn},this.getOptions=function(){return tn},this.getElement=function(){return J},this.reset=function(){for(var n in!this.is("destroyed")&&this.destroy(),cn.reset(),nn)nn[n]=!1;return this},this.go=function(){return nn.started?this:(function(){if(an){var n="[data-typeit-id='".concat(un,"'] .ti-cursor");g("@keyframes blink-".concat(un," { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } ").concat(n," { animation: blink-").concat(un," ").concat(tn.cursorSpeed/1e3,"s infinite; } ").concat(n,".with-delay { animation-delay: 500ms; } ").concat(n,".disabled { animation: none; }"),un),J.appendChild(an)}}(),tn.waitUntilVisible?(function(n,t){new IntersectionObserver((function(e,r){e.forEach((function(e){e.isIntersecting&&(t(),r.unobserve(n))}))}),{threshold:1}).observe(n)}(J,V.bind(this)),this):(V(),this))};var G,J="string"==typeof(G=t)?document.querySelector(G):G,W=T(J),X=[],Z=[],$=0,_={freezeCursor:!0},nn={started:!1,completed:!1,frozen:!1,destroyed:!1},tn=e(n,i);tn=e(tn,{html:!W&&tn.html,nextStringDelay:b(tn.nextStringDelay),loopDelay:b(tn.loopDelay)});var en,rn,on,un=Math.random().toString().substring(2,9),cn=new c([j,tn.startDelay]);J.setAttribute("data-typeit-id",un),g("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}"),tn.strings=(on=tn.strings,en=r(on)?on:[on],(rn=function(n){return n.innerHTML.replace(/<\!--.*?-->/g,"").trim()}(J))?(J.innerHTML="",tn.startDelete?(p(rn).forEach((function(n){L(J,n,an,$)})),cn.add([Y,!0]),q(1),en):[rn.trim()].concat(en)):en);var an=function(){if(W||!tn.cursor)return null;var n=y("span");return n.innerHTML=s(tn.cursorChar).innerHTML,n.className="ti-cursor",n.style.cssText="position:absolute;display:inline;margin-left:-.025em;".concat(function(n){var t=["font","lineHeight","color"],e=y("SPAN"),r=window.getComputedStyle(n,null);for(var i in r)t.indexOf(i)>-1&&r[i]&&(e.style[i]=r[i]);return e.style.cssText}(J)),n}();tn.strings.length&&function(){var n=tn.strings;n.forEach((function(t,e){var r=m(t,tn.html);cn.add(u(r,F,_,!0));var i=cn.getItems().length;if(e+1!==n.length){if(tn.breakLines){var o=v(y("BR"));return cn.add([F,o,_]),void q(i)}cn.add(u(r,Y,_)),q(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";var n={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(){}},t=function(n){return n.map((function(n){return void 0===n[1]&&n.push(null),void 0===n[2]&&n.push({}),n}))},e=function(n,t){return Object.assign({},n,t)},r=function(n){return Array.isArray(n)},i=function(n,t){return n[2]=e(n[2],t)||t,n},o=function(n,t){return r(n[0])?n.map((function(n){return i(n,t)})):i(n,t)},u=function(n,t,e,i){i=i||!1,e=e||{};var u=!r(n),c=n.length;return(n=u?new Array(n).fill(0):n).map((function(n,r){if(u)return t;var a=[t,n,e];return i&&(0===r&&(a=o(a,{isFirst:!0})),r+1===c&&(a=o(a,{isLast:!0}))),a}))};function c(n){this.insert=function(n,t){e.splice(n,0,t)},this.add=function(n,t,i){return n=r(n)?n:[n,null],i=i||!1,t=t||1,r(n[0])||(n=u(t,n)),e=i?n.concat(e):e.concat(n),this},this.delete=function(n){return e.splice(n,1),this},this.reset=function(){return e=t(e).map((function(n){return n[2].executed=!1,n})),this},this.getItems=function(){return t(e).filter((function(n){return!n.executed}))};var e=[];n&&this.add(n)}var a=function(n){return Array.from(n)},f=function(n){var t=[];return t.concat.apply(t,n)},s=function(n){var t=document.implementation.createHTMLDocument("");return t.body.innerHTML=n,t.body},l=function(n){return 3===n.nodeType||"BR"===n.tagName},d=function n(t,e,r){e=e||null,r=void 0!==r&&r;var i=a(t.childNodes).map((function(t){return l(t)?t:n(t)}));return i=f(i),e&&(i=i.filter((function(n){return!n.parentNode.isEqualNode(e)}))),r?i.reverse():i},h=function(n){return"BODY"===n.tagName},v=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 p(n){var t,e=s(n);return t=d(e).map((function(n){return n.nodeValue?a(n.nodeValue).map((function(t){return v(t,n)})):v(n)})),f(t)}function m(n,t){return(t=void 0===t||t)?p(n):a(n).map((function(n){return v(n)}))}var y=function(n){return document.createElement(n)},g=function(n,t){var e=y("style");e.id=t||"",e.appendChild(document.createTextNode(n)),document.head.appendChild(e)},b=function(n){return r(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 T=function(n){return["textarea","input"].indexOf(n.tagName.toLowerCase())>-1},x=function(n,t){var e=t.querySelectorAll("*");return[t].concat(a(e).reverse()).find((function(t){return t.cloneNode().outerHTML===n.outerHTML}))},N=function(n,t,e,r){e=e||null;var i=t.isHTMLElement,o=i?t.content:document.createTextNode(t.content);if(T(n))n.value="".concat(n.value).concat(t.content);else{if(!t.isTopLevelText&&!i){var u=t.node.parentNode,c=x(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=x(f,n);!s&&!h(a);)f.innerHTML=o.outerHTML,o=f,f=a.parentNode.cloneNode(),a=a.parentNode,s=x(f,n);n=s||n}}var l=d(n,e,!0)[r-1],v=l?l.parentNode:n;v.insertBefore(o,v.contains(e)?e:null)}},L=function(n){return n&&n.parentNode.removeChild(n)},w=function(n){return!n.firstChild&&!l(n)},M=function(n){return n.some((function(n){return w(n)}))};var D=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}},C=function(n){return window.getComputedStyle(n,null)};function E(n,t,e){return e?t?t(n):n:(n&&n.then||(n=Promise.resolve(n)),t?n.then(t):n)}function H(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 P(){}function z(n,t){if(!t)return n&&n.then?n.then(P):Promise.resolve()}function A(n,t){var e=n();return e&&e.then?e.then(t):t(e)}function k(n,t,e){if(!n.s){if(e instanceof O){if(!e.s)return void(e.o=k.bind(null,n,t));1&t&&(t=e.s),e=e.v}if(e&&e.then)return void e.then(k.bind(null,n,t),k.bind(null,n,2));n.s=t,n.v=e;var r=n.o;r&&r(n)}}var O=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{k(r,1,o(this.v))}catch(n){k(r,2,n)}return r}return this}return this.o=function(n){try{var i=n.v;1&n.s?k(r,1,t?t(i):i):e?k(r,1,e(i)):k(r,2,i)}catch(n){k(r,2,n)}},r},n}();function B(n,t){return n&&n.then?n.then(t):t(n)}return function(t,i){var o=this,f=this;i=i||{};var l=function(n,t){return fn.add(n,t),f},h=function(n){n=n||{};var t=e({},rn),r=e(t,n);return[[Y,r,{force:!0}],[Y,t,{force:!0}]]},x=function(){return Z?a(X.value):d(X,sn,!0)},q=function(n,t){t=t||1;var e=rn.nextStringDelay;fn.insert(n,[F,e.before]),fn.insert(n+t+1,[F,e.after])},I=function(){if(sn){var n="[data-typeit-id='".concat(an,"'] .ti-cursor");g("@keyframes blink-".concat(an," { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } ").concat(n," { animation: blink-").concat(an," ").concat(rn.cursorSpeed/1e3,"s infinite; } ").concat(n,".with-delay { animation-delay: 500ms; } ").concat(n,".disabled { animation: none; }"),an),X.appendChild(sn);var t,e,r=sn.getBoundingClientRect().width-(t=sn,(e=y("canvas").getContext("2d")).font=C(t).getPropertyValue("font-size"),e.measureText(t.innerText).width);sn.style.margin="0 -".concat(r,"px")}},R=function(n){sn&&(sn.classList.toggle("disabled",n),sn.classList.toggle("with-delay",!n))},V=H((function(n,t){return _.push(setTimeout(n,t)),E()})),j=H((function(n){return A((function(){if(nn)return z(move(-1*nn))}),(function(){fn.reset().delete(0).add([F,n.before],!0),x().forEach((function(n){fn.add([J,null,{isPhantom:!0}],1,!0)}))}))})),U=H((function(){en.started=!0;var n=fn.getItems();return B(function(n,t){try{var e=n()}catch(n){return t(n)}return e&&e.then?e.then(void 0,t):e}((function(){return B(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 O&&1&a.s))return void c.then(u,i||(i=k.bind(null,r=new O,2)));c=c.v}r?k(r,1,c):r=c}catch(n){k(r||(r=new O),2,n)}var a}(),r}(n,(function(t){if(en.frozen||en.destroyed)throw"";var e,r,i,u,c=n[t],a=c[2],f=[c,o];return a.freezeCursor&&R(!0),e=rn.speed,r=rn.deleteSpeed,i=rn.lifeLike,u=(r=null!==r?r:e/3)/2,$=i?[S(e,e/2),S(r,u)]:[e,r],A((function(){var n;if(null==a?void 0:a.isFirst)return z((n=rn).beforeString.apply(n,f))}),(function(){var n;return E((n=rn).beforeStep.apply(n,f),(function(){return E(c[0].call(o,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 z((t=rn).afterString.apply(t,f))}),(function(){var n;return E((n=rn).afterStep.apply(n,f),(function(){c[2].executed=!0}))}))}),(function(){R(!1)}))}))}))}))}),(function(){return!1})),(function(n){return en.completed=!0,E(rn.afterComplete(o),(function(){if(rn.loop){var n=rn.loopDelay||rn.nextStringDelay;V((function(){return E(j(n),(function(){U()}))}),n.after)}}))}))}),P),(function(n){return o}))})),F=function(n){return new Promise((function(t){V((function(){return t()}),n||rn.nextStringDelay.total)}))},K=function n(t){var e=x(),r=D(t,nn,e);return nn+=r.numberOfSteps,new Promise((function(t){V(H((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)}}(X,x(),sn,nn),A((function(){if(r.isString&&r.canKeepMoving)return z(n(r.numberOfSteps>0?"START":"END"))}),(function(){return t()}))})),$[0])}))},Q=function(n){return new Promise((function(t){V((function(){return N(X,n,sn,nn),t()}),$[0])}))},Y=H((function(n){rn=e(rn,n)})),G=H((function(){Z?X.value="":x().forEach((function(n){L(n)}))})),J=function n(t){return t=!0===t,new Promise((function(e){V(H((function(){var r=!1,i=x();return i.length&&(Z?X.value=X.value.slice(0,-1):L(i[nn])),function(n){for(var t=a(n.querySelectorAll("*")),e=M(t);t.length&&e;){var r=!1;t.forEach((function(n){w(n)&&(L(n),r=!0)})),r&&(t=a(n.querySelectorAll("*"))),e=M(t)}}(X),A((function(){if(t&&i.length-1>0)return E(n(!0),(function(){return r=!0,e()}))}),(function(n){return r?n:e()}))})),$[1])}))};this.break=function(){return l([Q,v(y("BR"))])},this.delete=function(n,t){var e=h(t);return fn.add(e[0]),fn.add([J,!n,tn],n||1),fn.add(e[1]),this},this.destroy=function(n){n=void 0===n||n,_.forEach((function(n){clearTimeout(n)})),_=[],n&&L(sn),en.destroyed=!0},this.empty=function(){return l(G)},this.exec=function(n,t){var e=h(t);return l([e[0],[n,null],e[1]])},this.is=function(n){return en[n]},this.move=function(n,t){var e=D(n,nn,x()),r=h(t);return fn.add(r[0]),fn.add([K,e.isString?n:Math.sign(n),tn],Math.abs(n)),fn.add(r[1]),this},this.freeze=function(){en.frozen=!0},this.unfreeze=function(){en.frozen=!1,!en.frozen&&U()},this.options=function(n){return l([Y,n])},this.pause=function(n){return l([F,n||null])},this.type=function(n,t){var e=h(t),r=m(n,rn.html),i=[e[0]].concat(u(r,Q,tn,!0),[e[1]]);return l(i)},this.getQueue=function(){return fn},this.getOptions=function(){return rn},this.getElement=function(){return X},this.reset=function(){for(var n in!this.is("destroyed")&&this.destroy(),fn.reset(),en)en[n]=!1;return this},this.go=function(){return en.started?this:(I(),rn.waitUntilVisible?(function(n,t){new IntersectionObserver((function(e,r){e.forEach((function(e){e.isIntersecting&&(t(),r.unobserve(n))}))}),{threshold:1}).observe(n)}(X,U.bind(this)),this):(U(),this))};var W,X="string"==typeof(W=t)?document.querySelector(W):W,Z=T(X),$=[],_=[],nn=0,tn={freezeCursor:!0},en={started:!1,completed:!1,frozen:!1,destroyed:!1},rn=e(n,i);rn=e(rn,{html:!Z&&rn.html,nextStringDelay:b(rn.nextStringDelay),loopDelay:b(rn.loopDelay)});var on,un,cn,an=Math.random().toString().substring(2,9),fn=new c([F,rn.startDelay]);X.setAttribute("data-typeit-id",an),g("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}"),rn.strings=(cn=rn.strings,on=r(cn)?cn:[cn],(un=function(n){return n.innerHTML.replace(/<\!--.*?-->/g,"").trim()}(X))?(X.innerHTML="",rn.startDelete?(p(un).forEach((function(n){N(X,n,sn,nn)})),fn.add([J,!0]),q(1),on):[un.trim()].concat(on)):on);var sn=function(){if(Z||!rn.cursor)return null;var n=y("span");return n.innerHTML=s(rn.cursorChar).innerHTML,n.className="ti-cursor",n.style.cssText="display:inline;".concat(function(n){var t=["font","lineHeight","color"],e=y("SPAN"),r=C(n);for(var i in r)t.indexOf(i)>-1&&r[i]&&(e.style[i]=r[i]);return e.style.cssText}(X)),n}();rn.strings.length&&function(){var n=rn.strings;n.forEach((function(t,e){var r=m(t,rn.html);fn.add(u(r,Q,tn,!0));var i=fn.getItems().length;if(e+1!==n.length){if(rn.breakLines){var o=v(y("BR"));return fn.add([Q,o,tn]),void q(i)}fn.add(u(r,J,tn)),q(i,t.length)}}))}()}})); |
{ | ||
"name": "typeit", | ||
"version": "7.0.0-rc5", | ||
"version": "7.0.0-rc6", | ||
"description": "The most versatile animated typing utility on the planet.", | ||
@@ -50,2 +50,3 @@ "author": "Alex MacArthur <alex@macarthur.me> (https://macarthur.me)", | ||
"husky": "^3.1.0", | ||
"jest-canvas-mock": "^2.2.0", | ||
"jest-cli": "^24.9.0", | ||
@@ -66,3 +67,4 @@ "prepack": "^0.2.54", | ||
"setupFiles": [ | ||
"./__tests__/setup.js" | ||
"./__tests__/setup.js", | ||
"jest-canvas-mock" | ||
] | ||
@@ -69,0 +71,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
52590
103
20