Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typeit

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typeit - npm Package Compare versions

Comparing version 5.5.1 to 5.5.2

18

dist/typeit.es.js

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

* Author: Alex MacArthur <alex@macarthur.me> (https://macarthur.me)
* Version: v5.5.1
* Version: v5.5.2
* URL: https://typeitjs.com

@@ -30,2 +30,12 @@ * License: GPL-2.0

if (!String.prototype.startsWith) {
Object.defineProperty(String.prototype, "startsWith", {
value: function value(search) {
return this.indexOf(search) === 0;
},
configurable: true,
writable: true
});
}
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {

@@ -201,3 +211,3 @@ return typeof obj;

var doc = document.implementation.createHTMLDocument();
var doc = document.implementation.createHTMLDocument("");
doc.body.innerHTML = string;

@@ -215,3 +225,3 @@

var matches = string[0].match(/\<(.*?)\>/);
var _doc = document.implementation.createHTMLDocument();
var _doc = document.implementation.createHTMLDocument("");
_doc.body.innerHTML = "<" + matches[1] + "></" + matches[1] + ">";

@@ -361,3 +371,3 @@

//-- If any of the existing children nodes have .ti-container, clear it out because this is a remnant of a previous instance.
this.element.childNodes.forEach(function (node) {
[].slice.call(this.element.childNodes).forEach(function (node) {
if (node.classList === undefined) return;

@@ -364,0 +374,0 @@

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

* Author: Alex MacArthur <alex@macarthur.me> (https://macarthur.me)
* Version: v5.5.1
* Version: v5.5.2
* URL: https://typeitjs.com

@@ -36,2 +36,12 @@ * License: GPL-2.0

if (!String.prototype.startsWith) {
Object.defineProperty(String.prototype, "startsWith", {
value: function value(search) {
return this.indexOf(search) === 0;
},
configurable: true,
writable: true
});
}
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {

@@ -207,3 +217,3 @@ return typeof obj;

var doc = document.implementation.createHTMLDocument();
var doc = document.implementation.createHTMLDocument("");
doc.body.innerHTML = string;

@@ -221,3 +231,3 @@

var matches = string[0].match(/\<(.*?)\>/);
var _doc = document.implementation.createHTMLDocument();
var _doc = document.implementation.createHTMLDocument("");
_doc.body.innerHTML = "<" + matches[1] + "></" + matches[1] + ">";

@@ -367,3 +377,3 @@

//-- If any of the existing children nodes have .ti-container, clear it out because this is a remnant of a previous instance.
this.element.childNodes.forEach(function (node) {
[].slice.call(this.element.childNodes).forEach(function (node) {
if (node.classList === undefined) return;

@@ -370,0 +380,0 @@

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

* Author: Alex MacArthur <alex@macarthur.me> (https://macarthur.me)
* Version: v5.5.1
* Version: v5.5.2
* URL: https://typeitjs.com

@@ -11,2 +11,2 @@ * License: GPL-2.0

*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.TypeIt=t()}(this,function(){"use strict";window.TypeItDefaults={strings:[],speed:100,deleteSpeed:void 0,lifeLike:!0,cursor:!0,cursorChar:"|",cursorSpeed:1e3,breakLines:!0,startDelay:250,startDelete:!1,nextStringDelay:750,loop:!1,loopDelay:750,html:!0,autoStart:!0,callback:function(){}};var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},n=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),i=function(){function e(n,i,s){t(this,e),this.timeouts=[],this.id=i,this.queue=[],this.hasStarted=!1,this.isFrozen=!1,this.isComplete=!1,this.isInTag=!1,this.stringsToDelete="",this.style="display:inline;position:relative;font:inherit;color:inherit;",this.element=n,this.setOptions(s,window.TypeItDefaults,!1),this.setNextStringDelay(),this.init()}return n(e,[{key:"setNextStringDelay",value:function(){var e=Array.isArray(this.options.nextStringDelay),t=e?null:this.options.nextStringDelay/2;this.options.nextStringDelay={before:e?this.options.nextStringDelay[0]:t,after:e?this.options.nextStringDelay[1]:t,total:e?this.options.nextStringDelay.reduce(function(e,t){return e+t}):this.options.nextStringDelay}}},{key:"init",value:function(){this.checkElement(),this.options.strings=this.toArray(this.options.strings),this.options.strings=this.removeComments(this.options.strings),this.options.strings.length>=1&&""===this.options.strings[0]||(this.element.innerHTML='\n <span style="'+this.style+'" class="ti-container"></span>\n ',this.element.setAttribute("data-typeitid",this.id),this.elementContainer=this.element.querySelector("span"),this.options.startDelete&&(this.insert(this.stringsToDelete),this.queue.push([this.delete]),this.insertSplitPause(1)),this.cursor(),this.generateQueue(),this.kickoff())}},{key:"removeComments",value:function(e){return e.map(function(e){return e.replace(/<\!--.*?-->/g,"")})}},{key:"generateQueue",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;t=null===t?[this.pause,this.options.startDelay]:t,this.queue.push(t),this.options.strings.forEach(function(t,n){e.queueUpString(t),n+1<e.options.strings.length&&(e.options.breakLines?(e.queue.push([e.break]),e.insertSplitPause(e.queue.length)):(e.queueUpDeletions(t),e.insertSplitPause(e.queue.length,t.length)))})}},{key:"queueUpDeletions",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t="string"==typeof e?e.length:e,n=0;n<t;n++)this.queue.push([this.delete,1])}},{key:"queueUpString",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(e){if(e=this.toArray(e),document.implementation.createHTMLDocument().body.innerHTML=e,t&&(e=(e=this.rake(e))[0]),this.options.html&&e[0].startsWith("<")&&!e[0].startsWith("</")){var n=e[0].match(/\<(.*?)\>/),i=document.implementation.createHTMLDocument();i.body.innerHTML="<"+n[1]+"></"+n[1]+">",this.queue.push([this.type,i.body.children[0]])}else this.queue.push([this.type,e[0]]);e.splice(0,1),e.length&&this.queueUpString(e,!1)}}},{key:"insertSplitPause",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.queue.splice(e,0,[this.pause,this.options.nextStringDelay.before]),this.queue.splice(e-t,0,[this.pause,this.options.nextStringDelay.after])}},{key:"kickoff",value:function(){if(this.options.autoStart)return this.hasStarted=!0,void this.next();if(this.isVisible())return this.hasStarted=!0,void this.next();var e=this;window.addEventListener("scroll",function t(n){e.isVisible()&&!e.hasStarted&&(e.hasStarted=!0,e.next(),n.currentTarget.removeEventListener(n.type,t))})}},{key:"isVisible",value:function(){var e=this.element.getBoundingClientRect(),t=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,n=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;return!(e.right>n||e.bottom>t)&&!(e.top<0||e.left<0)}},{key:"cursor",value:function(){var e="visibility: hidden;";if(this.options.cursor){var t=document.createElement("style");t.id=this.id;var n="\n @keyframes blink-"+this.id+" {\n 0% {opacity: 0}\n 49% {opacity: 0}\n 50% {opacity: 1}\n }\n\n [data-typeitid='"+this.id+"'] .ti-cursor {\n animation: blink-"+this.id+" "+this.options.cursorSpeed/1e3+"s infinite;\n }\n ";t.appendChild(document.createTextNode(n)),document.head.appendChild(t),e=""}this.element.insertAdjacentHTML("beforeend",'<span style="'+this.style+e+'" class="ti-cursor">'+this.options.cursorChar+"</span>")}},{key:"insert",value:function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]?this.elementContainer.lastChild.insertAdjacentHTML("beforeend",e):this.elementContainer.insertAdjacentHTML("beforeend",e),this.elementContainer.innerHTML=this.elementContainer.innerHTML.split("").join("")}},{key:"toArray",value:function(e){return e.constructor===Array?e.slice(0):e.split("<br>")}},{key:"checkElement",value:function(){var e=this;this.element.childNodes.forEach(function(t){void 0!==t.classList&&t.classList.contains("ti-container")&&(e.element.innerHTML="")}),!this.options.startDelete&&this.element.innerHTML.length>0?this.options.strings=this.element.innerHTML.trim():this.stringsToDelete=this.element.innerHTML}},{key:"break",value:function(){this.insert("<br>"),this.next()}},{key:"pause",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;setTimeout(function(){e.next()},null===t?this.options.nextStringDelay.total:t)}},{key:"rake",value:function(e){var t=this;return e.map(function(e){if(e=e.split(""),t.options.html)for(var n=[],i=void 0,s=!1,o=0;o<e.length;o++)"<"!==e[o]&&"&"!==e[o]||(n[0]=o,s="&"===e[o]),(">"===e[o]||";"===e[o]&&s)&&(n[1]=o,o=0,i=e.slice(n[0],n[1]+1).join(""),e.splice(n[0],n[1]-n[0]+1,i),s=!1);return e})}},{key:"type",value:function(e){var t=this;this.setPace(),this.timeouts[0]=setTimeout(function(){return"string"!=typeof e?(e.innerHTML="",t.elementContainer.appendChild(e),t.isInTag=!0,void t.next()):e.startsWith("</")?(t.isInTag=!1,void t.next()):(t.insert(e,t.isInTag),void t.next())},this.typePace)}},{key:"setOptions",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i={};for(var s in null===t&&(t=this.options),t)i[s]=t[s];for(var o in e)i[o]=e[o];this.options=i,n&&this.next()}},{key:"randomInRange",value:function(e,t){return Math.abs(Math.random()*(e+t-(e-t))+(e-t))}},{key:"setPace",value:function(){var e=this.options.speed,t=void 0!==this.options.deleteSpeed?this.options.deleteSpeed:this.options.speed/3,n=e/2,i=t/2;this.typePace=this.options.lifeLike?this.randomInRange(e,n):e,this.deletePace=this.options.lifeLike?this.randomInRange(t,i):t}},{key:"delete",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.timeouts[1]=setTimeout(function(){e.setPace();for(var n=e.elementContainer.innerHTML.split(""),i=n.length-1;i>-1;i--){if(">"!==n[i]&&";"!==n[i]||!e.options.html){n.pop();break}for(var s=i;s>-1;s--){if("<br>"===n.slice(s-3,s+1).join("")){n.splice(s-3,4);break}if("&"===n[s]){n.splice(s,i-s+1);break}if("<"===n[s]&&">"!==n[s-1]){if(";"===n[s-1])for(var o=s-1;o>-1;o--)if("&"===n[o]){n.splice(o,s-o);break}n.splice(s-1,1);break}}break}if(e.elementContainer.innerHTML.indexOf("></")>-1)for(var r=e.elementContainer.innerHTML.indexOf("></")-2;r>=0;r--)if("<"===n[r]){n.splice(r,n.length-r);break}e.elementContainer.innerHTML=n.join("").replace(/<[^\/>][^>]*><\/[^>]+>/,""),null===t&&e.queue.unshift([e.delete,n.length]),t>1&&e.queue.unshift([e.delete,t-1]),e.next()},this.deletePace)}},{key:"empty",value:function(){this.elementContainer.innerHTML="",this.next()}},{key:"next",value:function(){var e=this;if(!this.isFrozen){if(this.queue.length>0){var t=this.queue[0];return this.queue.shift(),void t[0].call(this,t[1])}this.options.callback(),this.options.loop?(this.queueUpDeletions(this.elementContainer.innerHTML),this.generateQueue([this.pause,this.options.loopDelay/2]),setTimeout(function(){e.next()},this.options.loopDelay/2)):this.isComplete=!0}}}]),e}();return function(){function s(n,i){t(this,s),this.id=this.generateHash(),this.instances=[],this.elements=[],this.args=i,"object"===(void 0===n?"undefined":e(n))&&(void 0===n.length?this.elements.push(n):this.elements=n),"string"==typeof n&&(this.elements=document.querySelectorAll(n)),this.createInstances()}return n(s,[{key:"generateHash",value:function(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}},{key:"createInstances",value:function(){var e=this;[].slice.call(this.elements).forEach(function(t){e.instances.push(new i(t,e.id,e.args))})}},{key:"pushAction",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.instances.forEach(function(n){n.queue.push([n[e],t]),!0===n.isComplete&&n.next()})}},{key:"type",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.instances.forEach(function(t){t.queueUpString(e),!0===t.isComplete&&t.next()}),this}},{key:"delete",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this.pushAction("delete",e),this}},{key:"freeze",value:function(){this.instances.forEach(function(e){e.isFrozen=!0})}},{key:"unfreeze",value:function(){this.instances.forEach(function(e){e.isFrozen&&(e.isFrozen=!1,e.next())})}},{key:"pause",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this.pushAction("pause",e),this}},{key:"destroy",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.instances.forEach(function(t){t.timeouts=t.timeouts.map(function(e){return clearTimeout(e),null}),e&&t.element.removeChild(t.element.querySelector(".ti-cursor"))}),this.instances=[]}},{key:"empty",value:function(){return this.pushAction("empty"),this}},{key:"break",value:function(){return this.pushAction("break"),this}},{key:"options",value:function(e){return this.pushAction("setOptions",e),this}},{key:"isComplete",get:function(){return this.instances[0].isComplete}}]),s}()});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.TypeIt=t()}(this,function(){"use strict";window.TypeItDefaults={strings:[],speed:100,deleteSpeed:void 0,lifeLike:!0,cursor:!0,cursorChar:"|",cursorSpeed:1e3,breakLines:!0,startDelay:250,startDelete:!1,nextStringDelay:750,loop:!1,loopDelay:750,html:!0,autoStart:!0,callback:function(){}},String.prototype.startsWith||Object.defineProperty(String.prototype,"startsWith",{value:function(e){return 0===this.indexOf(e)},configurable:!0,writable:!0});var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},i=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),n=function(){function e(i,n,s){t(this,e),this.timeouts=[],this.id=n,this.queue=[],this.hasStarted=!1,this.isFrozen=!1,this.isComplete=!1,this.isInTag=!1,this.stringsToDelete="",this.style="display:inline;position:relative;font:inherit;color:inherit;",this.element=i,this.setOptions(s,window.TypeItDefaults,!1),this.setNextStringDelay(),this.init()}return i(e,[{key:"setNextStringDelay",value:function(){var e=Array.isArray(this.options.nextStringDelay),t=e?null:this.options.nextStringDelay/2;this.options.nextStringDelay={before:e?this.options.nextStringDelay[0]:t,after:e?this.options.nextStringDelay[1]:t,total:e?this.options.nextStringDelay.reduce(function(e,t){return e+t}):this.options.nextStringDelay}}},{key:"init",value:function(){this.checkElement(),this.options.strings=this.toArray(this.options.strings),this.options.strings=this.removeComments(this.options.strings),this.options.strings.length>=1&&""===this.options.strings[0]||(this.element.innerHTML='\n <span style="'+this.style+'" class="ti-container"></span>\n ',this.element.setAttribute("data-typeitid",this.id),this.elementContainer=this.element.querySelector("span"),this.options.startDelete&&(this.insert(this.stringsToDelete),this.queue.push([this.delete]),this.insertSplitPause(1)),this.cursor(),this.generateQueue(),this.kickoff())}},{key:"removeComments",value:function(e){return e.map(function(e){return e.replace(/<\!--.*?-->/g,"")})}},{key:"generateQueue",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;t=null===t?[this.pause,this.options.startDelay]:t,this.queue.push(t),this.options.strings.forEach(function(t,i){e.queueUpString(t),i+1<e.options.strings.length&&(e.options.breakLines?(e.queue.push([e.break]),e.insertSplitPause(e.queue.length)):(e.queueUpDeletions(t),e.insertSplitPause(e.queue.length,t.length)))})}},{key:"queueUpDeletions",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t="string"==typeof e?e.length:e,i=0;i<t;i++)this.queue.push([this.delete,1])}},{key:"queueUpString",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(e){if(e=this.toArray(e),document.implementation.createHTMLDocument("").body.innerHTML=e,t&&(e=(e=this.rake(e))[0]),this.options.html&&e[0].startsWith("<")&&!e[0].startsWith("</")){var i=e[0].match(/\<(.*?)\>/),n=document.implementation.createHTMLDocument("");n.body.innerHTML="<"+i[1]+"></"+i[1]+">",this.queue.push([this.type,n.body.children[0]])}else this.queue.push([this.type,e[0]]);e.splice(0,1),e.length&&this.queueUpString(e,!1)}}},{key:"insertSplitPause",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.queue.splice(e,0,[this.pause,this.options.nextStringDelay.before]),this.queue.splice(e-t,0,[this.pause,this.options.nextStringDelay.after])}},{key:"kickoff",value:function(){if(this.options.autoStart)return this.hasStarted=!0,void this.next();if(this.isVisible())return this.hasStarted=!0,void this.next();var e=this;window.addEventListener("scroll",function t(i){e.isVisible()&&!e.hasStarted&&(e.hasStarted=!0,e.next(),i.currentTarget.removeEventListener(i.type,t))})}},{key:"isVisible",value:function(){var e=this.element.getBoundingClientRect(),t=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,i=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;return!(e.right>i||e.bottom>t)&&!(e.top<0||e.left<0)}},{key:"cursor",value:function(){var e="visibility: hidden;";if(this.options.cursor){var t=document.createElement("style");t.id=this.id;var i="\n @keyframes blink-"+this.id+" {\n 0% {opacity: 0}\n 49% {opacity: 0}\n 50% {opacity: 1}\n }\n\n [data-typeitid='"+this.id+"'] .ti-cursor {\n animation: blink-"+this.id+" "+this.options.cursorSpeed/1e3+"s infinite;\n }\n ";t.appendChild(document.createTextNode(i)),document.head.appendChild(t),e=""}this.element.insertAdjacentHTML("beforeend",'<span style="'+this.style+e+'" class="ti-cursor">'+this.options.cursorChar+"</span>")}},{key:"insert",value:function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]?this.elementContainer.lastChild.insertAdjacentHTML("beforeend",e):this.elementContainer.insertAdjacentHTML("beforeend",e),this.elementContainer.innerHTML=this.elementContainer.innerHTML.split("").join("")}},{key:"toArray",value:function(e){return e.constructor===Array?e.slice(0):e.split("<br>")}},{key:"checkElement",value:function(){var e=this;[].slice.call(this.element.childNodes).forEach(function(t){void 0!==t.classList&&t.classList.contains("ti-container")&&(e.element.innerHTML="")}),!this.options.startDelete&&this.element.innerHTML.length>0?this.options.strings=this.element.innerHTML.trim():this.stringsToDelete=this.element.innerHTML}},{key:"break",value:function(){this.insert("<br>"),this.next()}},{key:"pause",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;setTimeout(function(){e.next()},null===t?this.options.nextStringDelay.total:t)}},{key:"rake",value:function(e){var t=this;return e.map(function(e){if(e=e.split(""),t.options.html)for(var i=[],n=void 0,s=!1,o=0;o<e.length;o++)"<"!==e[o]&&"&"!==e[o]||(i[0]=o,s="&"===e[o]),(">"===e[o]||";"===e[o]&&s)&&(i[1]=o,o=0,n=e.slice(i[0],i[1]+1).join(""),e.splice(i[0],i[1]-i[0]+1,n),s=!1);return e})}},{key:"type",value:function(e){var t=this;this.setPace(),this.timeouts[0]=setTimeout(function(){return"string"!=typeof e?(e.innerHTML="",t.elementContainer.appendChild(e),t.isInTag=!0,void t.next()):e.startsWith("</")?(t.isInTag=!1,void t.next()):(t.insert(e,t.isInTag),void t.next())},this.typePace)}},{key:"setOptions",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n={};for(var s in null===t&&(t=this.options),t)n[s]=t[s];for(var o in e)n[o]=e[o];this.options=n,i&&this.next()}},{key:"randomInRange",value:function(e,t){return Math.abs(Math.random()*(e+t-(e-t))+(e-t))}},{key:"setPace",value:function(){var e=this.options.speed,t=void 0!==this.options.deleteSpeed?this.options.deleteSpeed:this.options.speed/3,i=e/2,n=t/2;this.typePace=this.options.lifeLike?this.randomInRange(e,i):e,this.deletePace=this.options.lifeLike?this.randomInRange(t,n):t}},{key:"delete",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.timeouts[1]=setTimeout(function(){e.setPace();for(var i=e.elementContainer.innerHTML.split(""),n=i.length-1;n>-1;n--){if(">"!==i[n]&&";"!==i[n]||!e.options.html){i.pop();break}for(var s=n;s>-1;s--){if("<br>"===i.slice(s-3,s+1).join("")){i.splice(s-3,4);break}if("&"===i[s]){i.splice(s,n-s+1);break}if("<"===i[s]&&">"!==i[s-1]){if(";"===i[s-1])for(var o=s-1;o>-1;o--)if("&"===i[o]){i.splice(o,s-o);break}i.splice(s-1,1);break}}break}if(e.elementContainer.innerHTML.indexOf("></")>-1)for(var r=e.elementContainer.innerHTML.indexOf("></")-2;r>=0;r--)if("<"===i[r]){i.splice(r,i.length-r);break}e.elementContainer.innerHTML=i.join("").replace(/<[^\/>][^>]*><\/[^>]+>/,""),null===t&&e.queue.unshift([e.delete,i.length]),t>1&&e.queue.unshift([e.delete,t-1]),e.next()},this.deletePace)}},{key:"empty",value:function(){this.elementContainer.innerHTML="",this.next()}},{key:"next",value:function(){var e=this;if(!this.isFrozen){if(this.queue.length>0){var t=this.queue[0];return this.queue.shift(),void t[0].call(this,t[1])}this.options.callback(),this.options.loop?(this.queueUpDeletions(this.elementContainer.innerHTML),this.generateQueue([this.pause,this.options.loopDelay/2]),setTimeout(function(){e.next()},this.options.loopDelay/2)):this.isComplete=!0}}}]),e}();return function(){function s(i,n){t(this,s),this.id=this.generateHash(),this.instances=[],this.elements=[],this.args=n,"object"===(void 0===i?"undefined":e(i))&&(void 0===i.length?this.elements.push(i):this.elements=i),"string"==typeof i&&(this.elements=document.querySelectorAll(i)),this.createInstances()}return i(s,[{key:"generateHash",value:function(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}},{key:"createInstances",value:function(){var e=this;[].slice.call(this.elements).forEach(function(t){e.instances.push(new n(t,e.id,e.args))})}},{key:"pushAction",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.instances.forEach(function(i){i.queue.push([i[e],t]),!0===i.isComplete&&i.next()})}},{key:"type",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.instances.forEach(function(t){t.queueUpString(e),!0===t.isComplete&&t.next()}),this}},{key:"delete",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this.pushAction("delete",e),this}},{key:"freeze",value:function(){this.instances.forEach(function(e){e.isFrozen=!0})}},{key:"unfreeze",value:function(){this.instances.forEach(function(e){e.isFrozen&&(e.isFrozen=!1,e.next())})}},{key:"pause",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this.pushAction("pause",e),this}},{key:"destroy",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.instances.forEach(function(t){t.timeouts=t.timeouts.map(function(e){return clearTimeout(e),null}),e&&t.element.removeChild(t.element.querySelector(".ti-cursor"))}),this.instances=[]}},{key:"empty",value:function(){return this.pushAction("empty"),this}},{key:"break",value:function(){return this.pushAction("break"),this}},{key:"options",value:function(e){return this.pushAction("setOptions",e),this}},{key:"isComplete",get:function(){return this.instances[0].isComplete}}]),s}()});
{
"name": "typeit",
"version": "5.5.1",
"version": "5.5.2",
"description": "The most versatile animated typing utility on the planet.",

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc