Comparing version 4.1.0 to 4.2.0
/** | ||
* jQuery TypeIt | ||
* @author Alex MacArthur (http://macarthur.me) | ||
* @version 4.1.0 | ||
* @version 4.2.0 | ||
* @copyright 2016 Alex MacArthur | ||
@@ -24,2 +24,3 @@ * @description Types out a given string or strings. | ||
speed: 100, | ||
deleteSpeed: undefined, | ||
lifeLike: true, | ||
@@ -135,4 +136,4 @@ cursor: true, | ||
// _randomize the timeout each time, if that's your thing | ||
this._random(this); | ||
// randomize the timeout each time, if that's your thing | ||
this._setPace(this); | ||
@@ -166,3 +167,3 @@ // "_print" the character | ||
}.bind(this), this.DT); | ||
}.bind(this), this.typePace); | ||
}, | ||
@@ -208,3 +209,3 @@ | ||
this._random(); | ||
this._setPace(); | ||
@@ -275,3 +276,3 @@ var a = this.tel.html().split(""); | ||
} | ||
}.bind(this), this.DT/3); | ||
}.bind(this), this.deletePace); | ||
}, | ||
@@ -350,8 +351,16 @@ | ||
_random : function() { | ||
var s = this.s.speed; | ||
var r = s/2; | ||
this.DT = this.s.lifeLike ? Math.abs(Math.random() * ((s+r) - (s-r)) + (s-r)) : s; | ||
_setPace : function() { | ||
var typeSpeed = this.s.speed; | ||
var deleteSpeed = this.s.deleteSpeed !== undefined ? this.s.deleteSpeed : this.s.speed/3; | ||
var typeRange = typeSpeed/2; | ||
var deleteRange = deleteSpeed/2; | ||
this.typePace = this.s.lifeLike ? this._randomInRange(typeSpeed, typeRange) : typeSpeed; | ||
this.deletePace = this.s.lifeLike ? this._randomInRange(deleteSpeed, deleteRange) : deleteSpeed; | ||
}, | ||
_randomInRange : function(value, range) { | ||
return Math.abs(Math.random() * ((value+range) - (value-range)) + (value-range)); | ||
}, | ||
/* | ||
@@ -358,0 +367,0 @@ Convert each string in the array to a sub-array. While happening, search the subarrays for HTML tags. |
@@ -1,1 +0,1 @@ | ||
!function(t,e){var s=t(document);t.fn.typeIt=function(i){return this.each(function(){var e=t(this);e.data("typeit",new t.typeIt(e,i))})},t.typeIt=function(i,e){this.d={strings:[],speed:100,lifeLike:!0,cursor:!0,cursorSpeed:1e3,breakLines:!0,breakDelay:750,startDelay:250,startDelete:!1,loop:!1,loopDelay:750,html:!0,autoStart:!0,callback:function(){}},this.queue=[],this.queueIndex=0,this.hasStarted=!1,this.inTag=!1,this.stringsToDelete="",this.style='style="display:inline;position:relative;font:inherit;color:inherit;"',this.s=t.extend({},this.d,e),this.el=i,this._init()},t.typeIt.prototype={_init:function(){this.el.find(".ti-container, .ti-cursor, .ti-placeholder").remove(),this._elCheck(),this.s.strings=this._toArray(this.s.strings),this.el.html('<i class="ti-placeholder" style="display:inline-block;width:0;line-height:0;overflow:hidden;">.</i><span '+this.style+' class="ti-container"></span>'),this.tel=this.el.find("span"),this.insert=function(t){this.tel.append(t)},this.s.startDelete&&(this.tel.html(this.stringsToDelete),this.queue.push([this["delete"]])),this._generateQueue(),this._kickoff()},_kickoff:function(){this._cursor(),this.s.autoStart?this._startQueue():this._isVisible()?(this.hasStarted=!0,this._startQueue()):s.on("scroll",function(){this._isVisible()&&!this.hasStarted&&(this.hasStarted=!0,this._startQueue())}.bind(this))},_generateQueue:function(){for(i=0;i<this.s.strings.length;i++)if(this.queue.push([this.type,this.s.strings[i]]),i<this.s.strings.length-1){var t=this.queue.length;this.queue.push([this.s.breakLines?this["break"]:this["delete"]]),this.s.breakLines&&(this.queue.splice(t,0,[this.pause,this.s.breakDelay/2]),this.queue.splice(t+2,0,[this.pause,this.s.breakDelay/2]))}},_startQueue:function(){this._to(function(){this._executeQueue()}.bind(this),this.s.startDelay)},type:function(t,i){i="undefined"==typeof i?!0:i,t=this._toArray(t),i&&(t=this._rake(t),t=t[0]),this.tTO=setTimeout(function(){if(this._random(this),this.s.html&&-1!==t[0].indexOf("<")&&-1===t[0].indexOf("</")&&!this.inTag){for(var i=t.length-1;i>=0;i--)-1!==t[i].indexOf("</")&&(this.tagCount=1,this.tagDuration=i);this._makeNode(t[0])}else this._print(t[0]);t.splice(0,1),t.length?this.type(t,!1):this._executeQueue()}.bind(this),this.DT)},pause:function(t){t=t===e?this.s.breakDelay:t,this._to(function(){this._executeQueue()}.bind(this),t)},"break":function(){this.insert("<br>"),this._executeQueue()},mergeSet:function(i){this.s=t.extend({},this.s,i),this._executeQueue()},_print:function(i){this.inTag?(t(this.tag,this.el).last().append(i),this.tagCount<this.tagDuration?this.tagCount++:this.inTag=!1):this.insert(i)},"delete":function(t){this.dTO=setTimeout(function(){this._random();for(var i=this.tel.html().split(""),s=t===e||null===t?i.length-1:t+1,h=i.length-1;h>-1;h--){if(">"!==i[h]&&";"!==i[h]||!this.s.html){i.pop();break}for(var n=h;n>-1;n--){if("<br>"===i.slice(n-3,n+1).join("")){i.splice(n-3,4);break}if("&"===i[n]){i.splice(n,h-n+1);break}if("<"===i[n]&&">"!==i[n-1]){if(";"===i[n-1])for(var u=n-1;u>-1;u--)if("&"===i[u]){i.splice(u,n-u);break}i.splice(n-1,1);break}}break}if(this.tel.html().indexOf("></")>-1)for(var r=this.tel.html().indexOf("></")-2;r>=0;r--)if("<"===i[r]){i.splice(r,i.length-r);break}this.tel.html(i.join("")),s>(t===e?0:2)?this["delete"](t===e?e:t-1):this._executeQueue()}.bind(this),this.DT/3)},_isVisible:function(){var i=t(window),e=i.scrollTop(),s=e+i.height(),h=this.el.offset().top,n=h+this.el.height();return s>=n&&h>=e},_executeQueue:function(){if(this.queueIndex<this.queue.length){var t=this.queue[this.queueIndex];this.queueIndex++,this.isLooping&&1===this.queueIndex?this._to(function(){t[0].bind(this)(t[1])}.bind(this),this.s.loopDelay/2):t[0].bind(this)(t[1])}else this.s.loop?(this.queueIndex=0,this.isLooping=!0,this._to(function(){this["delete"]()}.bind(this),this.s.loopDelay/2)):this.s.callback()},_to:function(t,i){setTimeout(function(){t()}.bind(this),i)},_elCheck:function(){!this.s.startDelete&&this.el.html().length>0?this.s.strings=this.el.html().trim():this.s.startDelete&&(this.stringsToDelete=this.el.html())},_toArray:function(t){return t.constructor===Array?t.slice(0):t.split("<br>")},_cursor:function(){if(this.s.cursor){this.el.append("<span "+this.style+'class="ti-cursor">|</span>');var t=this.s.cursorSpeed,i=this;!function e(){i.el.find(".ti-cursor").fadeTo(t/2,0).fadeTo(t/2,1),i._to(e,t)}()}},_random:function(){var t=this.s.speed,i=t/2;this.DT=this.s.lifeLike?Math.abs(Math.random()*(t+i-(t-i))+(t-i)):t},_rake:function(t){for(var i=0;i<t.length;i++)if(t[i]=t[i].split(""),this.s.html){this.tPos=[];for(var e,s=this.tPos,h=!1,n=0;n<t[i].length;n++)("<"===t[i][n]||"&"===t[i][n])&&(s[0]=n,h="&"===t[i][n]?!0:!1),(">"===t[i][n]||";"===t[i][n]&&h)&&(s[1]=n,n=0,e=t[i].slice(s[0],s[1]+1).join(""),t[i].splice(s[0],s[1]-s[0]+1,e),h=!1)}return t},_makeNode:function(i){this.tag=t(t.parseHTML(i)),this._print(this.tag),this.inTag=!0}},t.fn.tiType=function(i){var h=t(this).data("typeit");return h===e?s:(h.queue.push([h.type,i]),this)},t.fn.tiDelete=function(i){var h=t(this).data("typeit");return h===e?s:(h.queue.push([h["delete"],i]),this)},t.fn.tiPause=function(i){var h=t(this).data("typeit");return h===e?s:(h.queue.push([h.pause,i]),this)},t.fn.tiBreak=function(){var i=t(this).data("typeit");return i===e?s:(i.queue.push([i["break"]]),this)},t.fn.tiSettings=function(i){var h=t(this).data("typeit");return h===e?s:(h.queue.push([h.mergeSet,i]),this)}}(jQuery); | ||
!function(t,e){var s=t(document);t.fn.typeIt=function(e){return this.each(function(){var i=t(this);i.data("typeit",new t.typeIt(i,e))})},t.typeIt=function(i,s){this.d={strings:[],speed:100,deleteSpeed:e,lifeLike:!0,cursor:!0,cursorSpeed:1e3,breakLines:!0,breakDelay:750,startDelay:250,startDelete:!1,loop:!1,loopDelay:750,html:!0,autoStart:!0,callback:function(){}},this.queue=[],this.queueIndex=0,this.hasStarted=!1,this.inTag=!1,this.stringsToDelete="",this.style='style="display:inline;position:relative;font:inherit;color:inherit;"',this.s=t.extend({},this.d,s),this.el=i,this._init()},t.typeIt.prototype={_init:function(){this.el.find(".ti-container, .ti-cursor, .ti-placeholder").remove(),this._elCheck(),this.s.strings=this._toArray(this.s.strings),this.el.html('<i class="ti-placeholder" style="display:inline-block;width:0;line-height:0;overflow:hidden;">.</i><span '+this.style+' class="ti-container"></span>'),this.tel=this.el.find("span"),this.insert=function(t){this.tel.append(t)},this.s.startDelete&&(this.tel.html(this.stringsToDelete),this.queue.push([this["delete"]])),this._generateQueue(),this._kickoff()},_kickoff:function(){this._cursor(),this.s.autoStart?this._startQueue():this._isVisible()?(this.hasStarted=!0,this._startQueue()):s.on("scroll",function(){this._isVisible()&&!this.hasStarted&&(this.hasStarted=!0,this._startQueue())}.bind(this))},_generateQueue:function(){for(i=0;i<this.s.strings.length;i++)if(this.queue.push([this.type,this.s.strings[i]]),i<this.s.strings.length-1){var t=this.queue.length;this.queue.push([this.s.breakLines?this["break"]:this["delete"]]),this.s.breakLines&&(this.queue.splice(t,0,[this.pause,this.s.breakDelay/2]),this.queue.splice(t+2,0,[this.pause,this.s.breakDelay/2]))}},_startQueue:function(){this._to(function(){this._executeQueue()}.bind(this),this.s.startDelay)},type:function(t,e){e="undefined"==typeof e?!0:e,t=this._toArray(t),e&&(t=this._rake(t),t=t[0]),this.tTO=setTimeout(function(){if(this._setPace(this),this.s.html&&-1!==t[0].indexOf("<")&&-1===t[0].indexOf("</")&&!this.inTag){for(var e=t.length-1;e>=0;e--)-1!==t[e].indexOf("</")&&(this.tagCount=1,this.tagDuration=e);this._makeNode(t[0])}else this._print(t[0]);t.splice(0,1),t.length?this.type(t,!1):this._executeQueue()}.bind(this),this.typePace)},pause:function(t){t=t===e?this.s.breakDelay:t,this._to(function(){this._executeQueue()}.bind(this),t)},"break":function(){this.insert("<br>"),this._executeQueue()},mergeSet:function(e){this.s=t.extend({},this.s,e),this._executeQueue()},_print:function(e){this.inTag?(t(this.tag,this.el).last().append(e),this.tagCount<this.tagDuration?this.tagCount++:this.inTag=!1):this.insert(e)},"delete":function(t){this.dTO=setTimeout(function(){this._setPace();for(var i=this.tel.html().split(""),s=t===e||null===t?i.length-1:t+1,h=i.length-1;h>-1;h--){if(">"!==i[h]&&";"!==i[h]||!this.s.html){i.pop();break}for(var n=h;n>-1;n--){if("<br>"===i.slice(n-3,n+1).join("")){i.splice(n-3,4);break}if("&"===i[n]){i.splice(n,h-n+1);break}if("<"===i[n]&&">"!==i[n-1]){if(";"===i[n-1])for(var u=n-1;u>-1;u--)if("&"===i[u]){i.splice(u,n-u);break}i.splice(n-1,1);break}}break}if(this.tel.html().indexOf("></")>-1)for(var r=this.tel.html().indexOf("></")-2;r>=0;r--)if("<"===i[r]){i.splice(r,i.length-r);break}this.tel.html(i.join("")),s>(t===e?0:2)?this["delete"](t===e?e:t-1):this._executeQueue()}.bind(this),this.deletePace)},_isVisible:function(){var e=t(window),i=e.scrollTop(),s=i+e.height(),h=this.el.offset().top,n=h+this.el.height();return s>=n&&h>=i},_executeQueue:function(){if(this.queueIndex<this.queue.length){var t=this.queue[this.queueIndex];this.queueIndex++,this.isLooping&&1===this.queueIndex?this._to(function(){t[0].bind(this)(t[1])}.bind(this),this.s.loopDelay/2):t[0].bind(this)(t[1])}else this.s.loop?(this.queueIndex=0,this.isLooping=!0,this._to(function(){this["delete"]()}.bind(this),this.s.loopDelay/2)):this.s.callback()},_to:function(t,e){setTimeout(function(){t()}.bind(this),e)},_elCheck:function(){!this.s.startDelete&&this.el.html().length>0?this.s.strings=this.el.html().trim():this.s.startDelete&&(this.stringsToDelete=this.el.html())},_toArray:function(t){return t.constructor===Array?t.slice(0):t.split("<br>")},_cursor:function(){if(this.s.cursor){this.el.append("<span "+this.style+'class="ti-cursor">|</span>');var t=this.s.cursorSpeed,e=this;!function i(){e.el.find(".ti-cursor").fadeTo(t/2,0).fadeTo(t/2,1),e._to(i,t)}()}},_setPace:function(){var t=this.s.speed,i=this.s.deleteSpeed!==e?this.s.deleteSpeed:this.s.speed/3,s=t/2,h=i/2;this.typePace=this.s.lifeLike?this._randomInRange(t,s):t,this.deletePace=this.s.lifeLike?this._randomInRange(i,h):i},_randomInRange:function(t,e){return Math.abs(Math.random()*(t+e-(t-e))+(t-e))},_rake:function(t){for(var e=0;e<t.length;e++)if(t[e]=t[e].split(""),this.s.html){this.tPos=[];for(var i,s=this.tPos,h=!1,n=0;n<t[e].length;n++)("<"===t[e][n]||"&"===t[e][n])&&(s[0]=n,h="&"===t[e][n]?!0:!1),(">"===t[e][n]||";"===t[e][n]&&h)&&(s[1]=n,n=0,i=t[e].slice(s[0],s[1]+1).join(""),t[e].splice(s[0],s[1]-s[0]+1,i),h=!1)}return t},_makeNode:function(e){this.tag=t(t.parseHTML(e)),this._print(this.tag),this.inTag=!0}},t.fn.tiType=function(i){var h=t(this).data("typeit");return h===e?s:(h.queue.push([h.type,i]),this)},t.fn.tiDelete=function(i){var h=t(this).data("typeit");return h===e?s:(h.queue.push([h["delete"],i]),this)},t.fn.tiPause=function(i){var h=t(this).data("typeit");return h===e?s:(h.queue.push([h.pause,i]),this)},t.fn.tiBreak=function(){var i=t(this).data("typeit");return i===e?s:(i.queue.push([i["break"]]),this)},t.fn.tiSettings=function(i){var h=t(this).data("typeit");return h===e?s:(h.queue.push([h.mergeSet,i]),this)}}(jQuery); |
/** | ||
* jQuery TypeIt | ||
* @author Alex MacArthur (http://macarthur.me) | ||
* @version 4.1.0 | ||
* @version 4.2.0 | ||
* @copyright 2016 Alex MacArthur | ||
@@ -24,2 +24,3 @@ * @description Types out a given string or strings. | ||
speed: 100, | ||
deleteSpeed: undefined, | ||
lifeLike: true, | ||
@@ -135,4 +136,4 @@ cursor: true, | ||
// _randomize the timeout each time, if that's your thing | ||
this._random(this); | ||
// randomize the timeout each time, if that's your thing | ||
this._setPace(this); | ||
@@ -166,3 +167,3 @@ // "_print" the character | ||
}.bind(this), this.DT); | ||
}.bind(this), this.typePace); | ||
}, | ||
@@ -208,3 +209,3 @@ | ||
this._random(); | ||
this._setPace(); | ||
@@ -275,3 +276,3 @@ var a = this.tel.html().split(""); | ||
} | ||
}.bind(this), this.DT/3); | ||
}.bind(this), this.deletePace); | ||
}, | ||
@@ -350,8 +351,16 @@ | ||
_random : function() { | ||
var s = this.s.speed; | ||
var r = s/2; | ||
this.DT = this.s.lifeLike ? Math.abs(Math.random() * ((s+r) - (s-r)) + (s-r)) : s; | ||
_setPace : function() { | ||
var typeSpeed = this.s.speed; | ||
var deleteSpeed = this.s.deleteSpeed !== undefined ? this.s.deleteSpeed : this.s.speed/3; | ||
var typeRange = typeSpeed/2; | ||
var deleteRange = deleteSpeed/2; | ||
this.typePace = this.s.lifeLike ? this._randomInRange(typeSpeed, typeRange) : typeSpeed; | ||
this.deletePace = this.s.lifeLike ? this._randomInRange(deleteSpeed, deleteRange) : deleteSpeed; | ||
}, | ||
_randomInRange : function(value, range) { | ||
return Math.abs(Math.random() * ((value+range) - (value-range)) + (value-range)); | ||
}, | ||
/* | ||
@@ -358,0 +367,0 @@ Convert each string in the array to a sub-array. While happening, search the subarrays for HTML tags. |
@@ -1,1 +0,1 @@ | ||
!function(t,e){var s=t(document);t.fn.typeIt=function(i){return this.each(function(){var e=t(this);e.data("typeit",new t.typeIt(e,i))})},t.typeIt=function(i,e){this.d={strings:[],speed:100,lifeLike:!0,cursor:!0,cursorSpeed:1e3,breakLines:!0,breakDelay:750,startDelay:250,startDelete:!1,loop:!1,loopDelay:750,html:!0,autoStart:!0,callback:function(){}},this.queue=[],this.queueIndex=0,this.hasStarted=!1,this.inTag=!1,this.stringsToDelete="",this.style='style="display:inline;position:relative;font:inherit;color:inherit;"',this.s=t.extend({},this.d,e),this.el=i,this._init()},t.typeIt.prototype={_init:function(){this.el.find(".ti-container, .ti-cursor, .ti-placeholder").remove(),this._elCheck(),this.s.strings=this._toArray(this.s.strings),this.el.html('<i class="ti-placeholder" style="display:inline-block;width:0;line-height:0;overflow:hidden;">.</i><span '+this.style+' class="ti-container"></span>'),this.tel=this.el.find("span"),this.insert=function(t){this.tel.append(t)},this.s.startDelete&&(this.tel.html(this.stringsToDelete),this.queue.push([this["delete"]])),this._generateQueue(),this._kickoff()},_kickoff:function(){this._cursor(),this.s.autoStart?this._startQueue():this._isVisible()?(this.hasStarted=!0,this._startQueue()):s.on("scroll",function(){this._isVisible()&&!this.hasStarted&&(this.hasStarted=!0,this._startQueue())}.bind(this))},_generateQueue:function(){for(i=0;i<this.s.strings.length;i++)if(this.queue.push([this.type,this.s.strings[i]]),i<this.s.strings.length-1){var t=this.queue.length;this.queue.push([this.s.breakLines?this["break"]:this["delete"]]),this.s.breakLines&&(this.queue.splice(t,0,[this.pause,this.s.breakDelay/2]),this.queue.splice(t+2,0,[this.pause,this.s.breakDelay/2]))}},_startQueue:function(){this._to(function(){this._executeQueue()}.bind(this),this.s.startDelay)},type:function(t,i){i="undefined"==typeof i?!0:i,t=this._toArray(t),i&&(t=this._rake(t),t=t[0]),this.tTO=setTimeout(function(){if(this._random(this),this.s.html&&-1!==t[0].indexOf("<")&&-1===t[0].indexOf("</")&&!this.inTag){for(var i=t.length-1;i>=0;i--)-1!==t[i].indexOf("</")&&(this.tagCount=1,this.tagDuration=i);this._makeNode(t[0])}else this._print(t[0]);t.splice(0,1),t.length?this.type(t,!1):this._executeQueue()}.bind(this),this.DT)},pause:function(t){t=t===e?this.s.breakDelay:t,this._to(function(){this._executeQueue()}.bind(this),t)},"break":function(){this.insert("<br>"),this._executeQueue()},mergeSet:function(i){this.s=t.extend({},this.s,i),this._executeQueue()},_print:function(i){this.inTag?(t(this.tag,this.el).last().append(i),this.tagCount<this.tagDuration?this.tagCount++:this.inTag=!1):this.insert(i)},"delete":function(t){this.dTO=setTimeout(function(){this._random();for(var i=this.tel.html().split(""),s=t===e||null===t?i.length-1:t+1,h=i.length-1;h>-1;h--){if(">"!==i[h]&&";"!==i[h]||!this.s.html){i.pop();break}for(var n=h;n>-1;n--){if("<br>"===i.slice(n-3,n+1).join("")){i.splice(n-3,4);break}if("&"===i[n]){i.splice(n,h-n+1);break}if("<"===i[n]&&">"!==i[n-1]){if(";"===i[n-1])for(var u=n-1;u>-1;u--)if("&"===i[u]){i.splice(u,n-u);break}i.splice(n-1,1);break}}break}if(this.tel.html().indexOf("></")>-1)for(var r=this.tel.html().indexOf("></")-2;r>=0;r--)if("<"===i[r]){i.splice(r,i.length-r);break}this.tel.html(i.join("")),s>(t===e?0:2)?this["delete"](t===e?e:t-1):this._executeQueue()}.bind(this),this.DT/3)},_isVisible:function(){var i=t(window),e=i.scrollTop(),s=e+i.height(),h=this.el.offset().top,n=h+this.el.height();return s>=n&&h>=e},_executeQueue:function(){if(this.queueIndex<this.queue.length){var t=this.queue[this.queueIndex];this.queueIndex++,this.isLooping&&1===this.queueIndex?this._to(function(){t[0].bind(this)(t[1])}.bind(this),this.s.loopDelay/2):t[0].bind(this)(t[1])}else this.s.loop?(this.queueIndex=0,this.isLooping=!0,this._to(function(){this["delete"]()}.bind(this),this.s.loopDelay/2)):this.s.callback()},_to:function(t,i){setTimeout(function(){t()}.bind(this),i)},_elCheck:function(){!this.s.startDelete&&this.el.html().length>0?this.s.strings=this.el.html().trim():this.s.startDelete&&(this.stringsToDelete=this.el.html())},_toArray:function(t){return t.constructor===Array?t.slice(0):t.split("<br>")},_cursor:function(){if(this.s.cursor){this.el.append("<span "+this.style+'class="ti-cursor">|</span>');var t=this.s.cursorSpeed,i=this;!function e(){i.el.find(".ti-cursor").fadeTo(t/2,0).fadeTo(t/2,1),i._to(e,t)}()}},_random:function(){var t=this.s.speed,i=t/2;this.DT=this.s.lifeLike?Math.abs(Math.random()*(t+i-(t-i))+(t-i)):t},_rake:function(t){for(var i=0;i<t.length;i++)if(t[i]=t[i].split(""),this.s.html){this.tPos=[];for(var e,s=this.tPos,h=!1,n=0;n<t[i].length;n++)("<"===t[i][n]||"&"===t[i][n])&&(s[0]=n,h="&"===t[i][n]?!0:!1),(">"===t[i][n]||";"===t[i][n]&&h)&&(s[1]=n,n=0,e=t[i].slice(s[0],s[1]+1).join(""),t[i].splice(s[0],s[1]-s[0]+1,e),h=!1)}return t},_makeNode:function(i){this.tag=t(t.parseHTML(i)),this._print(this.tag),this.inTag=!0}},t.fn.tiType=function(i){var h=t(this).data("typeit");return h===e?s:(h.queue.push([h.type,i]),this)},t.fn.tiDelete=function(i){var h=t(this).data("typeit");return h===e?s:(h.queue.push([h["delete"],i]),this)},t.fn.tiPause=function(i){var h=t(this).data("typeit");return h===e?s:(h.queue.push([h.pause,i]),this)},t.fn.tiBreak=function(){var i=t(this).data("typeit");return i===e?s:(i.queue.push([i["break"]]),this)},t.fn.tiSettings=function(i){var h=t(this).data("typeit");return h===e?s:(h.queue.push([h.mergeSet,i]),this)}}(jQuery); | ||
!function(t,e){var s=t(document);t.fn.typeIt=function(e){return this.each(function(){var i=t(this);i.data("typeit",new t.typeIt(i,e))})},t.typeIt=function(i,s){this.d={strings:[],speed:100,deleteSpeed:e,lifeLike:!0,cursor:!0,cursorSpeed:1e3,breakLines:!0,breakDelay:750,startDelay:250,startDelete:!1,loop:!1,loopDelay:750,html:!0,autoStart:!0,callback:function(){}},this.queue=[],this.queueIndex=0,this.hasStarted=!1,this.inTag=!1,this.stringsToDelete="",this.style='style="display:inline;position:relative;font:inherit;color:inherit;"',this.s=t.extend({},this.d,s),this.el=i,this._init()},t.typeIt.prototype={_init:function(){this.el.find(".ti-container, .ti-cursor, .ti-placeholder").remove(),this._elCheck(),this.s.strings=this._toArray(this.s.strings),this.el.html('<i class="ti-placeholder" style="display:inline-block;width:0;line-height:0;overflow:hidden;">.</i><span '+this.style+' class="ti-container"></span>'),this.tel=this.el.find("span"),this.insert=function(t){this.tel.append(t)},this.s.startDelete&&(this.tel.html(this.stringsToDelete),this.queue.push([this["delete"]])),this._generateQueue(),this._kickoff()},_kickoff:function(){this._cursor(),this.s.autoStart?this._startQueue():this._isVisible()?(this.hasStarted=!0,this._startQueue()):s.on("scroll",function(){this._isVisible()&&!this.hasStarted&&(this.hasStarted=!0,this._startQueue())}.bind(this))},_generateQueue:function(){for(i=0;i<this.s.strings.length;i++)if(this.queue.push([this.type,this.s.strings[i]]),i<this.s.strings.length-1){var t=this.queue.length;this.queue.push([this.s.breakLines?this["break"]:this["delete"]]),this.s.breakLines&&(this.queue.splice(t,0,[this.pause,this.s.breakDelay/2]),this.queue.splice(t+2,0,[this.pause,this.s.breakDelay/2]))}},_startQueue:function(){this._to(function(){this._executeQueue()}.bind(this),this.s.startDelay)},type:function(t,e){e="undefined"==typeof e?!0:e,t=this._toArray(t),e&&(t=this._rake(t),t=t[0]),this.tTO=setTimeout(function(){if(this._setPace(this),this.s.html&&-1!==t[0].indexOf("<")&&-1===t[0].indexOf("</")&&!this.inTag){for(var e=t.length-1;e>=0;e--)-1!==t[e].indexOf("</")&&(this.tagCount=1,this.tagDuration=e);this._makeNode(t[0])}else this._print(t[0]);t.splice(0,1),t.length?this.type(t,!1):this._executeQueue()}.bind(this),this.typePace)},pause:function(t){t=t===e?this.s.breakDelay:t,this._to(function(){this._executeQueue()}.bind(this),t)},"break":function(){this.insert("<br>"),this._executeQueue()},mergeSet:function(e){this.s=t.extend({},this.s,e),this._executeQueue()},_print:function(e){this.inTag?(t(this.tag,this.el).last().append(e),this.tagCount<this.tagDuration?this.tagCount++:this.inTag=!1):this.insert(e)},"delete":function(t){this.dTO=setTimeout(function(){this._setPace();for(var i=this.tel.html().split(""),s=t===e||null===t?i.length-1:t+1,h=i.length-1;h>-1;h--){if(">"!==i[h]&&";"!==i[h]||!this.s.html){i.pop();break}for(var n=h;n>-1;n--){if("<br>"===i.slice(n-3,n+1).join("")){i.splice(n-3,4);break}if("&"===i[n]){i.splice(n,h-n+1);break}if("<"===i[n]&&">"!==i[n-1]){if(";"===i[n-1])for(var u=n-1;u>-1;u--)if("&"===i[u]){i.splice(u,n-u);break}i.splice(n-1,1);break}}break}if(this.tel.html().indexOf("></")>-1)for(var r=this.tel.html().indexOf("></")-2;r>=0;r--)if("<"===i[r]){i.splice(r,i.length-r);break}this.tel.html(i.join("")),s>(t===e?0:2)?this["delete"](t===e?e:t-1):this._executeQueue()}.bind(this),this.deletePace)},_isVisible:function(){var e=t(window),i=e.scrollTop(),s=i+e.height(),h=this.el.offset().top,n=h+this.el.height();return s>=n&&h>=i},_executeQueue:function(){if(this.queueIndex<this.queue.length){var t=this.queue[this.queueIndex];this.queueIndex++,this.isLooping&&1===this.queueIndex?this._to(function(){t[0].bind(this)(t[1])}.bind(this),this.s.loopDelay/2):t[0].bind(this)(t[1])}else this.s.loop?(this.queueIndex=0,this.isLooping=!0,this._to(function(){this["delete"]()}.bind(this),this.s.loopDelay/2)):this.s.callback()},_to:function(t,e){setTimeout(function(){t()}.bind(this),e)},_elCheck:function(){!this.s.startDelete&&this.el.html().length>0?this.s.strings=this.el.html().trim():this.s.startDelete&&(this.stringsToDelete=this.el.html())},_toArray:function(t){return t.constructor===Array?t.slice(0):t.split("<br>")},_cursor:function(){if(this.s.cursor){this.el.append("<span "+this.style+'class="ti-cursor">|</span>');var t=this.s.cursorSpeed,e=this;!function i(){e.el.find(".ti-cursor").fadeTo(t/2,0).fadeTo(t/2,1),e._to(i,t)}()}},_setPace:function(){var t=this.s.speed,i=this.s.deleteSpeed!==e?this.s.deleteSpeed:this.s.speed/3,s=t/2,h=i/2;this.typePace=this.s.lifeLike?this._randomInRange(t,s):t,this.deletePace=this.s.lifeLike?this._randomInRange(i,h):i},_randomInRange:function(t,e){return Math.abs(Math.random()*(t+e-(t-e))+(t-e))},_rake:function(t){for(var e=0;e<t.length;e++)if(t[e]=t[e].split(""),this.s.html){this.tPos=[];for(var i,s=this.tPos,h=!1,n=0;n<t[e].length;n++)("<"===t[e][n]||"&"===t[e][n])&&(s[0]=n,h="&"===t[e][n]?!0:!1),(">"===t[e][n]||";"===t[e][n]&&h)&&(s[1]=n,n=0,i=t[e].slice(s[0],s[1]+1).join(""),t[e].splice(s[0],s[1]-s[0]+1,i),h=!1)}return t},_makeNode:function(e){this.tag=t(t.parseHTML(e)),this._print(this.tag),this.inTag=!0}},t.fn.tiType=function(i){var h=t(this).data("typeit");return h===e?s:(h.queue.push([h.type,i]),this)},t.fn.tiDelete=function(i){var h=t(this).data("typeit");return h===e?s:(h.queue.push([h["delete"],i]),this)},t.fn.tiPause=function(i){var h=t(this).data("typeit");return h===e?s:(h.queue.push([h.pause,i]),this)},t.fn.tiBreak=function(){var i=t(this).data("typeit");return i===e?s:(i.queue.push([i["break"]]),this)},t.fn.tiSettings=function(i){var h=t(this).data("typeit");return h===e?s:(h.queue.push([h.mergeSet,i]),this)}}(jQuery); |
{ | ||
"name": "typeit", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"license": "GPL-2.0", | ||
"author": "Alex MacArthur <alex@macarthur.me>", | ||
"description": "A versatile, easy-to-implement jQuery animated typing plugin that types text for you.", | ||
"description": "The most versatile jQuery animated typing plugin on the planet.", | ||
"license": "General Public License", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -51,3 +51,3 @@ # TypeIt: The Most Versatile jQuery Animated Typing Plugin on the Planet | ||
* <strong><a href="https://www.jsdelivr.com/projects/jquery.typeit">CDN:</a></strong> Include `https://cdn.jsdelivr.net/jquery.typeit/4.0.1/typeit.min.js` or `https://cdnjs.cloudflare.com/ajax/libs/typeit/4.0.1/typeit.min.js` on your page. | ||
* <strong><a href="https://www.jsdelivr.com/projects/jquery.typeit">CDN:</a></strong> Include `https://cdn.jsdelivr.net/jquery.typeit/4.2.0/typeit.min.js` or `https://cdnjs.cloudflare.com/ajax/libs/typeit/4.2.0/typeit.min.js` on your page. | ||
* <strong><a href="https://www.npmjs.com/package/typeit">npm:</a></strong> Install with `npm install typeit`. | ||
@@ -60,3 +60,3 @@ | ||
```html | ||
<script src="jquery-2.1.4.min.js"></script> | ||
<script src="jquery.js"></script> | ||
<script src="typeit.js"></script> | ||
@@ -63,0 +63,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
212299
1282