Comparing version 7.0.0-rc1 to 7.0.0-rc10
/** | ||
* TypeIt - The most versatile animated typing utility on the planet. | ||
* Author: Alex MacArthur <alex@macarthur.me> (https://macarthur.me) | ||
* Version: v6.5.1 | ||
* Version: v7.0.0-rc10 | ||
* 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,t)=>(e[2]=n(e[2],t)||t,e),i=(e,t)=>Array.isArray(e[0])?e.map(e=>r(e,t)):r(e,t),o=(e,t,n,r)=>{r=r||!1,n=n||{};var o=!Array.isArray(e),a=e.length;return(e=o?new Array(e).fill(0):e).map((e,u)=>{if(o)return t;var s=[t,e,n];return r&&(0===u&&(s=i(s,{isFirst:!0})),u+1===a&&(s=i(s,{isLast:!0}))),s})};function a(e){this.insert=function(e,t){n.splice(e,0,t)},this.add=function(e,t,r){return e=Array.isArray(e)?e:[e,null],r=r||!1,t=t||1,Array.isArray(e[0])||(e=o(t,e)),n=r?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 u=e=>Array.from(e),s=e=>{var t=[];return t.concat.apply(t,e)},c=e=>{var t=document.implementation.createHTMLDocument("");return t.body.innerHTML=e,t.body},l=e=>3===e.nodeType||"BR"===e.tagName,f=(e,t,n)=>{t=t||null,n=void 0!==n&&n;var r=u(e.childNodes).map(e=>l(e)?e:f(e));return r=s(r),t&&(r=r.filter(e=>!e.parentNode.isEqualNode(t))),n?r.reverse():r},d=(e,t)=>{t=t||null;var n=e instanceof HTMLElement;return{node:t,isTopLevelText:!(t&&"BODY"!==t.parentNode.tagName||n),isHTMLElement:n,content:e}};function h(e){var t,n=c(e);return t=f(n).map(e=>e.nodeValue?u(e.nodeValue).map(t=>d(t,e)):d(e)),s(t)}function v(e,t){return(t=void 0===t||t)?h(e):u(e).map(e=>d(e))}var p=e=>document.createElement(e),m=(e,t)=>{var n=p("style");n.id=t||"",n.appendChild(document.createTextNode(e)),document.head.appendChild(n)},y=e=>(Array.isArray(e)||(e=[e/2,e/2]),{before:e[0],after:e[1],total:e[0]+e[1]}),g=(e,t)=>Math.abs(Math.random()*(e+t-(e-t))+(e-t));var b=e=>["textarea","input"].indexOf(e.tagName.toLowerCase())>-1,S=(e,t)=>{var n=t.querySelectorAll("*");return[t].concat(u(n).reverse()).find(t=>t.cloneNode().outerHTML===e.outerHTML)},N=(e,t,n,r)=>{n=n||null;var i=t.isHTMLElement,o=i?t.content:document.createTextNode(t.content);if(b(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,"BODY"!==a.parentNode.tagName){for(var s=a.parentNode,c=s.cloneNode(),l=S(c,e);!l&&"BODY"!==s.tagName;)c.innerHTML=o.outerHTML,o=c,c=s.parentNode.cloneNode(),s=s.parentNode,l=S(c,e);l&&(e=l)}}var d=f(e,n,!0);d=d[r-1],d=e.querySelector(".ti-cursor")||d,e.insertBefore(o,d||null)}},T=e=>e&&e.parentNode.removeChild(e),L=e=>!e.firstChild&&!l(e),A=e=>e.some(e=>L(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 M(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function x(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 w(){}function E(e,t){if(!t)return e&&e.then?e.then(w):Promise.resolve()}function C(e,t){var n=e();return n&&n.then?n.then(t):t(n)}function H(e,t,n){if(!e.s){if(n instanceof O){if(!n.s)return void(n.o=H.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(H.bind(null,e,t),H.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{H(r,1,o(this.v))}catch(e){H(r,2,e)}return r}return this}return this.o=function(e){try{var i=e.v;1&e.s?H(r,1,t?t(i):i):n?H(r,1,n(i)):H(r,2,i)}catch(e){H(r,2,e)}},r},e}();function P(e,t){return e&&e.then?e.then(t):t(e)}export default function(t,r){var i=this;r=r||{};var s=(e,t)=>(ie.add(e,t),this),l=e=>{e=e||{};var t=n({},_),r=n(t,e);return[[Y,r,{force:!0}],[Y,t,{force:!0}]]},S=()=>G?u(Q.value):f(Q,oe,!0),k=(e,t)=>{t=t||1;var n=_.nextStringDelay;ie.insert(e,[R,n.before]),ie.insert(e+t+1,[R,n.after])},z=e=>{oe&&(oe.classList.toggle("disabled",e),oe.classList.toggle("with-delay",!e))},B=x((function(e,t){return W.push(setTimeout(e,t)),M()})),q=x((function(e){return C((function(){if(X)return E(move(-1*X))}),(function(){ie.reset().delete(0).add([R,e.before],!0),S().forEach(e=>{ie.add([F,null,{isPhantom:!0}],1,!0)})}))})),I=x((function(){$.started=!0;var e=ie.getItems();return P(function(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}((function(){return P(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=H.bind(null,r=new O,2)));u=u.v}r?H(r,1,u):r=u}catch(e){H(r||(r=new O),2,e)}var s}(),r}(e,(function(t){if($.frozen||$.destroyed)throw"";var n,r,o,a,u=e[t],s=u[2],c=[u,ie,i];return s.freezeCursor&&z(!0),n=_.speed,r=_.deleteSpeed,o=_.lifeLike,a=(r=null!==r?r:n/3)/2,J=o?[g(n,n/2),g(r,a)]:[n,r],C((function(){var e;if(null==s?void 0:s.isFirst)return E((e=_).beforeString.apply(e,c))}),(function(){var e;return M((e=_).beforeStep.apply(e,c),(function(){return M(u[0].call(i,u[1],s),(function(){return C((function(){if(!s||!s.isPhantom)return C((function(){var e,t;if(null===(e=u[2])||void 0===e?void 0:e.isLast)return E((t=_).afterString.apply(t,c))}),(function(){var e;return M((e=_).afterStep.apply(e,c),(function(){u[2].executed=!0}))}))}),(function(){z(!1)}))}))}))}))}),(function(){return!1})),(function(e){return $.completed=!0,M(_.afterComplete(i),(function(){if(_.loop){var e=_.loopDelay||_.nextStringDelay;B((function(){return M(q(e),(function(){I()}))}),e.after)}}))}))}),w),(function(e){return i}))})),R=e=>new Promise(t=>{B(()=>t(),e||_.nextStringDelay.total)}),V=e=>{var t=S(),n=D(e,X,t);return X+=n.numberOfSteps,new Promise(e=>{B(x((function(){return((e,t,n,r)=>{if(n){var i=r,o=t[(i=i>t.length?t.length:i)-1];e.insertBefore(n,o||null)}})(Q,S(),oe,X),C((function(){if(n.isString&&n.canKeepMoving)return E(V(n.numberOfSteps>0?"START":"END"))}),(function(){return e()}))})),J[0])})},U=e=>new Promise(t=>{B(()=>(N(Q,e,oe,X),t()),J[0])}),Y=x((function(e){_=n(_,e)})),j=x((function(){G?Q.value="":S().forEach(e=>{T(e)})})),F=e=>(e=!0===e,new Promise(t=>{B(x((function(){var n=!1,r=S();return r.length&&(G?Q.value=Q.value.slice(0,-1):T(r[X])),(e=>{for(var t=u(e.querySelectorAll("*")),n=A(t);t.length&&n;){var r=!1;t.forEach(e=>{L(e)&&(T(e),r=!0)}),r&&(t=u(e.querySelectorAll("*"))),n=A(t)}})(Q),C((function(){if(e&&r.length-1>0)return M(F(!0),(function(){return n=!0,t()}))}),(function(e){return n?e:t()}))})),J[1])}));this.break=function(){return ie.add([U,p("BR")])},this.delete=function(e,t){var n=l(t);return ie.add(n[0]),ie.add([F,!e,Z],e||1),ie.add(n[1]),this},this.destroy=function(e){e=void 0===e||e,W.forEach(e=>{clearTimeout(e)}),W=[],e&&T(oe),$.destroyed=!0},this.empty=function(){return s(j)},this.exec=function(e,t){var n=l(t);return s([n[0],[e,null],n[1]])},this.is=function(e){return $[e]},this.move=function(e,t){var n=D(e,X,S()),r=l(t);return ie.add(r[0]),ie.add([V,n.isString?e:Math.sign(e),Z],Math.abs(e)),ie.add(r[1]),this},this.freeze=function(){$.frozen=!0},this.unfreeze=function(){$.frozen=!1,!$.frozen&&I()},this.options=function(e){return s([Y,e])},this.pause=function(e){return s([R,e||null])},this.type=function(e,t){var n=l(t),r=v(e,_.html),i=[n[0]].concat(o(r,U,Z,!0),[n[1]]);return s(i)},this.getQueue=function(){return ie},this.getOptions=function(){return _},this.reset=function(){for(var e in!this.is("destroyed")&&this.destroy(),ie.reset(),$)$[e]=!1;return this},this.go=function(){return $.started?this:((()=>{if(oe){var e="[data-typeit-id='".concat(re,"'] .ti-cursor");m("@keyframes blink-".concat(re," { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } ").concat(e," { animation: blink-").concat(re," ").concat(_.cursorSpeed/1e3,"s infinite; } ").concat(e,".with-delay { animation-delay: 500ms; } ").concat(e,".disabled { animation: none; }"),re),Q.appendChild(oe)}})(),_.waitUntilVisible?(((e,t)=>{new IntersectionObserver((n,r)=>{n.forEach(n=>{n.isIntersecting&&(t(),r.unobserve(e))})},{threshold:1}).observe(e)})(Q,I.bind(this)),this):(I(),this))};var K,Q="string"==typeof(K=t)?document.querySelector(K):K,G=b(Q),J=[],W=[],X=0,Z={freezeCursor:!0},$={started:!1,completed:!1,frozen:!1,destroyed:!1},_=n(e,r);_=n(_,{html:!G&&_.html,nextStringDelay:y(_.nextStringDelay),loopDelay:y(_.loopDelay)});var ee,te,ne,re=Math.random().toString().substring(2,9),ie=new a([R,_.startDelay]);Q.setAttribute("data-typeit-id",re),m("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}"),_.strings=(ne=_.strings,ee=Array.isArray(ne)?ne:[ne],(te=(e=>e.innerHTML.replace(/<\!--.*?-->/g,"").trim())(Q))?(Q.innerHTML="",_.startDelete?(h(te).forEach(e=>{N(Q,e,oe,X)}),ie.add([F,!0]),k(1),ee):[te.trim()].concat(ee)):ee);var oe=(()=>{if(G||!_.cursor)return null;var e=p("span");return e.innerHTML=c(_.cursorChar).innerHTML,e.className="ti-cursor",e.setAttribute("style","display:inline;position:absolute;font:inherit;color:inherit;line-height:inherit;margin-left:-.1em;"),e})();_.strings.length&&(()=>{var e=_.strings;e.forEach((t,n)=>{var r=v(t,_.html);ie.add(o(r,U,Z,!0));var i=ie.getItems().length;if(n+1!==e.length){if(_.breakLines){var a=d(p("BR"));return ie.add([U,a,Z]),void k(i)}ie.add(o(r,F,Z)),k(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){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)).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=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)).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=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)}})})()} |
/** | ||
* TypeIt - The most versatile animated typing utility on the planet. | ||
* Author: Alex MacArthur <alex@macarthur.me> (https://macarthur.me) | ||
* Version: v6.5.1 | ||
* Version: v7.0.0-rc10 | ||
* 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,t){return n[2]=e(n[2],t)||t,n},i=function(n,t){return Array.isArray(n[0])?n.map((function(n){return r(n,t)})):r(n,t)},o=function(n,t,e,r){r=r||!1,e=e||{};var o=!Array.isArray(n),u=n.length;return(n=o?new Array(n).fill(0):n).map((function(n,a){if(o)return t;var c=[t,n,e];return r&&(0===a&&(c=i(c,{isFirst:!0})),a+1===u&&(c=i(c,{isLast:!0}))),c}))};function u(n){this.insert=function(n,t){e.splice(n,0,t)},this.add=function(n,t,r){return n=Array.isArray(n)?n:[n,null],r=r||!1,t=t||1,Array.isArray(n[0])||(n=o(t,n)),e=r?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)},c=function(n){var t=[];return t.concat.apply(t,n)},f=function(n){var t=document.implementation.createHTMLDocument("");return t.body.innerHTML=n,t.body},s=function(n){return 3===n.nodeType||"BR"===n.tagName},l=function n(t,e,r){e=e||null,r=void 0!==r&&r;var i=a(t.childNodes).map((function(t){return s(t)?t:n(t)}));return i=c(i),e&&(i=i.filter((function(n){return!n.parentNode.isEqualNode(e)}))),r?i.reverse():i},d=function(n,t){t=t||null;var e=n instanceof HTMLElement;return{node:t,isTopLevelText:!(t&&"BODY"!==t.parentNode.tagName||e),isHTMLElement:e,content:n}};function h(n){var t,e=f(n);return t=l(e).map((function(n){return n.nodeValue?a(n.nodeValue).map((function(t){return d(t,n)})):d(n)})),c(t)}function v(n,t){return(t=void 0===t||t)?h(n):a(n).map((function(n){return d(n)}))}var p=function(n){return document.createElement(n)},y=function(n,t){var e=p("style");e.id=t||"",e.appendChild(document.createTextNode(n)),document.head.appendChild(e)},m=function(n){return Array.isArray(n)||(n=[n/2,n/2]),{before:n[0],after:n[1],total:n[0]+n[1]}},g=function(n,t){return Math.abs(Math.random()*(n+t-(n-t))+(n-t))};var b=function(n){return["textarea","input"].indexOf(n.tagName.toLowerCase())>-1},S=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(b(n))n.value="".concat(n.value).concat(t.content);else{if(!t.isTopLevelText&&!i){var u=t.node.parentNode,a=S(u.cloneNode(),n);if(function(n,t){if(!n)return!1;var e=n.nextSibling;return!e||e.isEqualNode(t)}(a,e))n=a;else if((o=u.cloneNode()).innerText=t.content,"BODY"!==u.parentNode.tagName){for(var c=u.parentNode,f=c.cloneNode(),s=S(f,n);!s&&"BODY"!==c.tagName;)f.innerHTML=o.outerHTML,o=f,f=c.parentNode.cloneNode(),c=c.parentNode,s=S(f,n);s&&(n=s)}}var d=l(n,e,!0);d=d[r-1],d=n.querySelector(".ti-cursor")||d,n.insertBefore(o,d||null)}},T=function(n){return n&&n.parentNode.removeChild(n)},L=function(n){return!n.firstChild&&!s(n)},x=function(n){return n.some((function(n){return L(n)}))};var A=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 D(n,t,e){return e?t?t(n):n:(n&&n.then||(n=Promise.resolve(n)),t?n.then(t):n)}function M(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 w(){}function E(n,t){if(!t)return n&&n.then?n.then(w):Promise.resolve()}function C(n,t){var e=n();return e&&e.then?e.then(t):t(e)}function H(n,t,e){if(!n.s){if(e instanceof O){if(!e.s)return void(e.o=H.bind(null,n,t));1&t&&(t=e.s),e=e.v}if(e&&e.then)return void e.then(H.bind(null,n,t),H.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{H(r,1,o(this.v))}catch(n){H(r,2,n)}return r}return this}return this.o=function(n){try{var i=n.v;1&n.s?H(r,1,t?t(i):i):e?H(r,1,e(i)):H(r,2,i)}catch(n){H(r,2,n)}},r},n}();function P(n,t){return n&&n.then?n.then(t):t(n)}return function(t,r){var i=this,c=this;r=r||{};var s=function(n,t){return un.add(n,t),c},S=function(n){n=n||{};var t=e({},nn),r=e(t,n);return[[Y,r,{force:!0}],[Y,t,{force:!0}]]},k=function(){return J?a(G.value):l(G,an,!0)},z=function(n,t){t=t||1;var e=nn.nextStringDelay;un.insert(n,[V,e.before]),un.insert(n+t+1,[V,e.after])},B=function(n){an&&(an.classList.toggle("disabled",n),an.classList.toggle("with-delay",!n))},q=M((function(n,t){return X.push(setTimeout(n,t)),D()})),I=M((function(n){return C((function(){if(Z)return E(move(-1*Z))}),(function(){un.reset().delete(0).add([V,n.before],!0),k().forEach((function(n){un.add([K,null,{isPhantom:!0}],1,!0)}))}))})),R=M((function(){_.started=!0;var n=un.getItems();return P(function(n,t){try{var e=n()}catch(n){return t(n)}return e&&e.then?e.then(void 0,t):e}((function(){return P(function(n,t,e){var r,i,o=-1;return function u(a){try{for(;++o<n.length&&(!e||!e());)if((a=t(o))&&a.then){if(!((c=a)instanceof O&&1&c.s))return void a.then(u,i||(i=H.bind(null,r=new O,2)));a=a.v}r?H(r,1,a):r=a}catch(n){H(r||(r=new O),2,n)}var c}(),r}(n,(function(t){if(_.frozen||_.destroyed)throw"";var e,r,o,u,a=n[t],c=a[2],f=[a,un,i];return c.freezeCursor&&B(!0),e=nn.speed,r=nn.deleteSpeed,o=nn.lifeLike,u=(r=null!==r?r:e/3)/2,W=o?[g(e,e/2),g(r,u)]:[e,r],C((function(){var n;if(null==c?void 0:c.isFirst)return E((n=nn).beforeString.apply(n,f))}),(function(){var n;return D((n=nn).beforeStep.apply(n,f),(function(){return D(a[0].call(i,a[1],c),(function(){return C((function(){if(!c||!c.isPhantom)return C((function(){var n,t;if(null===(n=a[2])||void 0===n?void 0:n.isLast)return E((t=nn).afterString.apply(t,f))}),(function(){var n;return D((n=nn).afterStep.apply(n,f),(function(){a[2].executed=!0}))}))}),(function(){B(!1)}))}))}))}))}),(function(){return!1})),(function(n){return _.completed=!0,D(nn.afterComplete(i),(function(){if(nn.loop){var n=nn.loopDelay||nn.nextStringDelay;q((function(){return D(I(n),(function(){R()}))}),n.after)}}))}))}),w),(function(n){return i}))})),V=function(n){return new Promise((function(t){q((function(){return t()}),n||nn.nextStringDelay.total)}))},j=function n(t){var e=k(),r=A(t,Z,e);return Z+=r.numberOfSteps,new Promise((function(t){q(M((function(){return function(n,t,e,r){if(e){var i=r,o=t[(i=i>t.length?t.length:i)-1];n.insertBefore(e,o||null)}}(G,k(),an,Z),C((function(){if(r.isString&&r.canKeepMoving)return E(n(r.numberOfSteps>0?"START":"END"))}),(function(){return t()}))})),W[0])}))},U=function(n){return new Promise((function(t){q((function(){return N(G,n,an,Z),t()}),W[0])}))},Y=M((function(n){nn=e(nn,n)})),F=M((function(){J?G.value="":k().forEach((function(n){T(n)}))})),K=function n(t){return t=!0===t,new Promise((function(e){q(M((function(){var r=!1,i=k();return i.length&&(J?G.value=G.value.slice(0,-1):T(i[Z])),function(n){for(var t=a(n.querySelectorAll("*")),e=x(t);t.length&&e;){var r=!1;t.forEach((function(n){L(n)&&(T(n),r=!0)})),r&&(t=a(n.querySelectorAll("*"))),e=x(t)}}(G),C((function(){if(t&&i.length-1>0)return D(n(!0),(function(){return r=!0,e()}))}),(function(n){return r?n:e()}))})),W[1])}))};this.break=function(){return un.add([U,p("BR")])},this.delete=function(n,t){var e=S(t);return un.add(e[0]),un.add([K,!n,$],n||1),un.add(e[1]),this},this.destroy=function(n){n=void 0===n||n,X.forEach((function(n){clearTimeout(n)})),X=[],n&&T(an),_.destroyed=!0},this.empty=function(){return s(F)},this.exec=function(n,t){var e=S(t);return s([e[0],[n,null],e[1]])},this.is=function(n){return _[n]},this.move=function(n,t){var e=A(n,Z,k()),r=S(t);return un.add(r[0]),un.add([j,e.isString?n:Math.sign(n),$],Math.abs(n)),un.add(r[1]),this},this.freeze=function(){_.frozen=!0},this.unfreeze=function(){_.frozen=!1,!_.frozen&&R()},this.options=function(n){return s([Y,n])},this.pause=function(n){return s([V,n||null])},this.type=function(n,t){var e=S(t),r=v(n,nn.html),i=[e[0]].concat(o(r,U,$,!0),[e[1]]);return s(i)},this.getQueue=function(){return un},this.getOptions=function(){return nn},this.reset=function(){for(var n in!this.is("destroyed")&&this.destroy(),un.reset(),_)_[n]=!1;return this},this.go=function(){return _.started?this:(function(){if(an){var n="[data-typeit-id='".concat(on,"'] .ti-cursor");y("@keyframes blink-".concat(on," { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } ").concat(n," { animation: blink-").concat(on," ").concat(nn.cursorSpeed/1e3,"s infinite; } ").concat(n,".with-delay { animation-delay: 500ms; } ").concat(n,".disabled { animation: none; }"),on),G.appendChild(an)}}(),nn.waitUntilVisible?(function(n,t){new IntersectionObserver((function(e,r){e.forEach((function(e){e.isIntersecting&&(t(),r.unobserve(n))}))}),{threshold:1}).observe(n)}(G,R.bind(this)),this):(R(),this))};var Q,G="string"==typeof(Q=t)?document.querySelector(Q):Q,J=b(G),W=[],X=[],Z=0,$={freezeCursor:!0},_={started:!1,completed:!1,frozen:!1,destroyed:!1},nn=e(n,r);nn=e(nn,{html:!J&&nn.html,nextStringDelay:m(nn.nextStringDelay),loopDelay:m(nn.loopDelay)});var tn,en,rn,on=Math.random().toString().substring(2,9),un=new u([V,nn.startDelay]);G.setAttribute("data-typeit-id",on),y("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}"),nn.strings=(rn=nn.strings,tn=Array.isArray(rn)?rn:[rn],(en=function(n){return n.innerHTML.replace(/<\!--.*?-->/g,"").trim()}(G))?(G.innerHTML="",nn.startDelete?(h(en).forEach((function(n){N(G,n,an,Z)})),un.add([K,!0]),z(1),tn):[en.trim()].concat(tn)):tn);var an=function(){if(J||!nn.cursor)return null;var n=p("span");return n.innerHTML=f(nn.cursorChar).innerHTML,n.className="ti-cursor",n.setAttribute("style","display:inline;position:absolute;font:inherit;color:inherit;line-height:inherit;margin-left:-.1em;"),n}();nn.strings.length&&function(){var n=nn.strings;n.forEach((function(t,e){var r=v(t,nn.html);un.add(o(r,U,$,!0));var i=un.getItems().length;if(e+1!==n.length){if(nn.breakLines){var u=d(p("BR"));return un.add([U,u,$]),void z(i)}un.add(o(r,K,$)),z(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,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)).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=M(n,_,O()),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&&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)}}))}()}})); |
{ | ||
"name": "typeit", | ||
"version": "7.0.0-rc1", | ||
"version": "7.0.0-rc10", | ||
"description": "The most versatile animated typing utility on the planet.", | ||
@@ -41,5 +41,5 @@ "author": "Alex MacArthur <alex@macarthur.me> (https://macarthur.me)", | ||
"@babel/cli": "^7.8.4", | ||
"@babel/core": "^7.8.4", | ||
"@babel/core": "^7.8.7", | ||
"@babel/plugin-transform-spread": "^7.8.3", | ||
"@babel/preset-env": "^7.8.4", | ||
"@babel/preset-env": "^7.8.7", | ||
"babel-jest": "^24.9.0", | ||
@@ -51,2 +51,3 @@ "babel-loader": "^8.0.6", | ||
"husky": "^3.1.0", | ||
"jest-canvas-mock": "^2.2.0", | ||
"jest-cli": "^24.9.0", | ||
@@ -56,7 +57,7 @@ "prepack": "^0.2.54", | ||
"pretty-quick": "^2.0.1", | ||
"rollup": "^1.27.12", | ||
"rollup-plugin-babel": "^4.3.3", | ||
"rollup": "^1.32.1", | ||
"rollup-plugin-babel": "^4.4.0", | ||
"rollup-plugin-execute": "^1.1.1", | ||
"rollup-plugin-prepack": "^1.1.1", | ||
"rollup-plugin-terser": "^5.2.0" | ||
"rollup-plugin-terser": "^5.3.0" | ||
}, | ||
@@ -68,3 +69,4 @@ "jest": { | ||
"setupFiles": [ | ||
"./__tests__/setup.js" | ||
"./__tests__/setup.js", | ||
"jest-canvas-mock" | ||
] | ||
@@ -71,0 +73,0 @@ }, |
@@ -58,2 +58,3 @@ # TypeIt | ||
- `IntersectionObserver` | ||
- `Math.sign` | ||
- `Object.assign` | ||
@@ -65,3 +66,3 @@ - `Promise` | ||
```html | ||
<script src="https://polyfill.io/v3/polyfill.min.js?features=Array.prototype.fill%2CIntersectionObserver%2CObject.assign%2CPromise%2CArray.from%2CArray.prototype.find"></script> | ||
<script src="https://polyfill.io/v3/polyfill.min.js?features=Array.prototype.fill%2CIntersectionObserver%2CObject.assign%2CPromise%2CArray.from%2CArray.prototype.find%2CMath.sign"></script> | ||
``` | ||
@@ -68,0 +69,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
52852
104
83
20