Comparing version 2.0.1 to 2.0.2
/** | ||
* jQuery TypeIt | ||
* @author Alex MacArthur (http://macarthur.me) | ||
* @version 2.0.1 | ||
* @version 2.0.2 | ||
* @copyright 2016 Alex MacArthur | ||
@@ -128,7 +128,6 @@ * @description Types out a given string or strings. | ||
// if there's a string already typed in the element, replace whatToType with it | ||
if(this.theElement.text().length > 0 && !this.theElement.has('.ti-container')) { | ||
this.settings.whatToType = this.theElement.html(); | ||
if(this.theElement.text().length > 0) { | ||
this.settings.whatToType = this.theElement.text().trim(); | ||
} | ||
}; | ||
@@ -135,0 +134,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(t,e){t.fn.typeIt=function(e,i){return this.each(function(){t(this).data("typeit",new t.fn.typeIt.typeItClass(t(this),e,i))})},t.fn.typeIt.typeItClass=function(e,i,n){this.defaults={whatToType:"You probably want to use your own string.",typeSpeed:100,lifeLike:!0,showCursor:!0,breakLines:!0,breakDelay:750,startDelay:250,loop:!1,loopDelay:750},this.dataAttDefaults={whatToType:e.data("typeitWhattotype"),typeSpeed:e.data("typeitTypespeed"),lifeLike:e.data("typeitLifelike"),showCursor:e.data("typeitShowcursor"),breakLines:e.data("typeitBreaklines"),breakDelay:e.data("typeitBreakdelay"),startDelay:e.data("typeitStartdelay"),loop:e.data("typeitLoop"),loopDelay:e.data("typeitLoopdelay")},this.settings={},t.extend(this.settings,this.defaults,i,this.dataAttDefaults),this.theElement=e,this.callback=n,this.init(i)},_proto=t.fn.typeIt.typeItClass.prototype,_proto.init=function(t){return this.stringPlaceCount=0,this.phraseLength=0,this.stringArray=[],this.stringArrayIndex=0,this.stringArrayCharacterIndex=0,this.contentStartEnd=[],this.contentStartEndIndex=0,this.contentStartEndSpan=0,this.printingInTag=!1,this.characterToAppend=null,this.thisTiTextContainer=null,this.thisString=null,this.thisTag=null,this.stringLengths=[],this.stringToDelete=null,this.typeTimeout=null,this.deleteTimeout=null,this.typeSpeedRangeSpan=null,this.typeSpeedMin=null,this.typeSpeedMax=null,this.validateCallbackFunction()===!1?!1:(this.testForElementStringOverride(),this.processWhatToType(),this.setupDOMComponents(),void setTimeout(function(){this.typeLoop()}.bind(this),this.settings.startDelay))},_proto.testForElementStringOverride=function(){this.theElement.text().length>0&&!this.theElement.has(".ti-container")&&(this.settings.whatToType=this.theElement.html())},_proto.setupDOMComponents=function(){for(this.theElement.html(""),j=0;j<this.stringArray.length;j++)this.stringLengths[j]=this.stringArray[j].length,this.theElement.append('<span class="ti-container"><span class="ti-text-container ti-cursor"></span></span>');this.theElement.find(".ti-container:first-child").find(".ti-text-container").addClass("active-container"),this.settings.breakLines===!1&&(this.theElement.find(".ti-container").remove(),this.theElement.append('<span class="ti-container"><span class="ti-text-container ti-cursor"></span></span>')),this.settings.showCursor===!1&&this.theElement.find(".ti-text-container").removeClass("ti-cursor")},_proto.processWhatToType=function(){if("[object Array]"!==Object.prototype.toString.call(this.settings.whatToType))this.stringArray='["'+this.settings.whatToType+'"]',this.stringArray=JSON.parse(this.stringArray);else{this.stringArrayTemp=t.extend({},this.settings.whatToType),this.stringArrayTemp=t.map(this.stringArrayTemp,function(t,e){return[t]});for(var e=0;e<this.stringArrayTemp.length;e++)this.stringArray.push(this.stringArrayTemp[e])}for(var i=0;i<this.stringArray.length;i++){this.contentStartEnd=[],this.contentStartEndIndex=0,this.contentStartEndSpan=0,this.stringArray[i]=this.stringArray[i].split("");for(var n=0,s=this.stringArray[i];n<s.length;n++)"<"===s[n]&&(this.contentStartEnd[this.contentStartEndIndex]=[],this.contentStartEnd[this.contentStartEndIndex][0]=n),">"===s[n]&&(this.contentStartEnd[this.contentStartEndIndex][1]=n,this.contentStartEndIndex++);for(var r=0;r<this.contentStartEnd.length;r++)for(var a=this.contentStartEnd[r][0];a<this.contentStartEnd[r][1];a++)this.stringArray[i][this.contentStartEnd[r][0]]=this.stringArray[i][this.contentStartEnd[r][0]]+this.stringArray[i][a+1];for(var h=0;h<this.contentStartEnd.length;h++){var o=this.contentStartEnd[h][0]+1;this.stringArray[i].splice(o,this.contentStartEnd[h][1]-this.contentStartEnd[h][0]);for(var p=this.contentStartEnd[h][1]-this.contentStartEnd[h][0],d=0;d<this.contentStartEnd.length;d++)this.contentStartEnd[d][0]=this.contentStartEnd[d][0]-p,this.contentStartEnd[d][1]=this.contentStartEnd[d][1]-p}}},_proto.validateCallbackFunction=function(){"undefined"==typeof this.callback&&(this.callback=function(){return!0})},_proto.randomizeTypeSpeed=function(){this.settings.lifeLike===!0?(this.typeSpeedRangeSpan=this.settings.typeSpeed/2,this.typeSpeedMin=this.settings.typeSpeed-this.typeSpeedRangeSpan,this.typeSpeedMax=this.settings.typeSpeed+this.typeSpeedRangeSpan,this.delayTime=Math.abs(Math.random()*(this.typeSpeedMax-this.typeSpeedMin)+this.typeSpeedMin)):this.delayTime=this.settings.typeSpeed},_proto.typeLoop=function(){this.thisString=this.stringArray[this.stringArrayIndex],this.phraseLength=this.thisString.length,this.typeTimeout=setTimeout(function(){if(this.randomizeTypeSpeed(),this.characterToAppend=this.stringArray[this.stringArrayIndex][this.stringArrayCharacterIndex],-1!==this.characterToAppend.indexOf("<")&&-1===this.characterToAppend.indexOf("</")){this.contentStartEndIndex=0,this.contentStartEnd[0]=this.stringArrayCharacterIndex+1;for(var e=this.stringArrayCharacterIndex;e<this.thisString.length;e++)if(-1!==this.thisString[e].indexOf("</")){this.contentStartEnd[1]=e-1;break}this.contentStartEndSpan=this.contentStartEnd[1]-this.contentStartEnd[0],this.thisTag=t(t.parseHTML(this.characterToAppend)),this.characterToAppend=this.thisTag,this.appendTheCharacter(),this.printingInTag=!0}this.appendTheCharacter(),this.stringArrayCharacterIndex++,this.stringArrayCharacterIndex<this.phraseLength?this.typeLoop():this.stringArray.length>1?(this.stringArrayCharacterIndex=0,this.stringPlaceCount=this.stringPlaceCount+this.phraseLength,this.stringArrayIndex+1===this.stringArray.length?this.endOfStringsFork():this.stringArrayIndex+1<this.stringArray.length&&this.settings.breakLines===!1?setTimeout(function(){this.deleteLoop()}.bind(this),this.settings.breakDelay):this.stringArrayIndex+1<this.stringArray.length&&this.settings.breakLines===!0&&(this.stringArrayIndex++,setTimeout(function(){this.theElement.find(".ti-text-container").removeClass("active-container"),this.theElement.find(".ti-text-container:eq("+this.stringArrayIndex+")").addClass("active-container"),setTimeout(function(){this.typeLoop()}.bind(this),this.settings.breakDelay)}.bind(this),this.settings.breakDelay))):this.endOfStringsFork()}.bind(this),this.delayTime)},_proto.endOfStringsFork=function(){this.settings.loop===!0?setTimeout(function(){this.deleteLoop()}.bind(this),this.settings.loopDelay):this.callback()},_proto.appendTheCharacter=function(){this.settings.breakLines===!0?(this.thisTiTextContainer=this.theElement.find(".ti-text-container:eq("+this.stringArrayIndex+")"),this.thisTiTextContainer.addClass("active-container")):(this.thisTiTextContainer=this.theElement.find(".ti-text-container"),this.thisTiTextContainer.addClass("active-container")),this.appendToHTMLTag(function(){this.thisTiTextContainer.append(this.characterToAppend)}.bind(this))},_proto.appendToHTMLTag=function(e){this.printingInTag===!0?(this.characterToAppend=this.thisString[this.contentStartEnd[0]+this.contentStartEndIndex],t(this.thisTag,this.theElement).last().append(this.characterToAppend),this.printingInTag=this.contentStartEnd[1]===this.contentStartEnd[0]+this.contentStartEndIndex-1?!1:!0,this.contentStartEndIndex++):e()},_proto.deleteLoop=function(t){this.thisTiTextContainer=this.theElement.find(".ti-text-container"),this.deleteTimeout=setTimeout(function(){this.randomizeTypeSpeed(),this.stringToDelete=this.thisTiTextContainer.last().html(),this.arrayToDelete=typeof this.arrayToDelete!==t?this.stringToDelete.split(""):[];for(var e=this.arrayToDelete.length-1;e>-1;e--){if(">"===this.arrayToDelete[e]){for(var i=e-1;i>-1;i--)if("<"===this.arrayToDelete[i]&&">"!==this.arrayToDelete[i-1]){this.arrayToDelete.splice(i-1,1);break}break}this.arrayToDelete.splice(e,1);break}this.thisTiTextContainer.last().html(this.arrayToDelete.join("")),0===this.thisTiTextContainer.last().text().length&&this.thisTiTextContainer.last().html(""),this.thisTiTextContainer.last().text().length>0?this.deleteLoop():this.stringArray[this.stringArrayIndex+1]!==t?(this.stringArrayIndex++,this.typeLoop()):this.settings.loop===!0&&(this.thisTiTextContainer.length>1?(this.thisTiTextContainer.last().remove(),this.theElement.find(".ti-text-container").last().addClass("active-container"),this.deleteLoop()):this.init())}.bind(this),this.delayTime/3)},_proto.stop=function(){clearTimeout(this.typeTimeout),clearTimeout(this.deleteTimeout)}}(jQuery); | ||
!function(t,e){t.fn.typeIt=function(e,i){return this.each(function(){t(this).data("typeit",new t.fn.typeIt.typeItClass(t(this),e,i))})},t.fn.typeIt.typeItClass=function(e,i,n){this.defaults={whatToType:"You probably want to use your own string.",typeSpeed:100,lifeLike:!0,showCursor:!0,breakLines:!0,breakDelay:750,startDelay:250,loop:!1,loopDelay:750},this.dataAttDefaults={whatToType:e.data("typeitWhattotype"),typeSpeed:e.data("typeitTypespeed"),lifeLike:e.data("typeitLifelike"),showCursor:e.data("typeitShowcursor"),breakLines:e.data("typeitBreaklines"),breakDelay:e.data("typeitBreakdelay"),startDelay:e.data("typeitStartdelay"),loop:e.data("typeitLoop"),loopDelay:e.data("typeitLoopdelay")},this.settings={},t.extend(this.settings,this.defaults,i,this.dataAttDefaults),this.theElement=e,this.callback=n,this.init(i)},_proto=t.fn.typeIt.typeItClass.prototype,_proto.init=function(t){return this.stringPlaceCount=0,this.phraseLength=0,this.stringArray=[],this.stringArrayIndex=0,this.stringArrayCharacterIndex=0,this.contentStartEnd=[],this.contentStartEndIndex=0,this.contentStartEndSpan=0,this.printingInTag=!1,this.characterToAppend=null,this.thisTiTextContainer=null,this.thisString=null,this.thisTag=null,this.stringLengths=[],this.stringToDelete=null,this.typeTimeout=null,this.deleteTimeout=null,this.typeSpeedRangeSpan=null,this.typeSpeedMin=null,this.typeSpeedMax=null,this.validateCallbackFunction()===!1?!1:(this.testForElementStringOverride(),this.processWhatToType(),this.setupDOMComponents(),void setTimeout(function(){this.typeLoop()}.bind(this),this.settings.startDelay))},_proto.testForElementStringOverride=function(){this.theElement.text().length>0&&(this.settings.whatToType=this.theElement.text().trim())},_proto.setupDOMComponents=function(){for(this.theElement.html(""),j=0;j<this.stringArray.length;j++)this.stringLengths[j]=this.stringArray[j].length,this.theElement.append('<span class="ti-container"><span class="ti-text-container ti-cursor"></span></span>');this.theElement.find(".ti-container:first-child").find(".ti-text-container").addClass("active-container"),this.settings.breakLines===!1&&(this.theElement.find(".ti-container").remove(),this.theElement.append('<span class="ti-container"><span class="ti-text-container ti-cursor"></span></span>')),this.settings.showCursor===!1&&this.theElement.find(".ti-text-container").removeClass("ti-cursor")},_proto.processWhatToType=function(){if("[object Array]"!==Object.prototype.toString.call(this.settings.whatToType))this.stringArray='["'+this.settings.whatToType+'"]',this.stringArray=JSON.parse(this.stringArray);else{this.stringArrayTemp=t.extend({},this.settings.whatToType),this.stringArrayTemp=t.map(this.stringArrayTemp,function(t,e){return[t]});for(var e=0;e<this.stringArrayTemp.length;e++)this.stringArray.push(this.stringArrayTemp[e])}for(var i=0;i<this.stringArray.length;i++){this.contentStartEnd=[],this.contentStartEndIndex=0,this.contentStartEndSpan=0,this.stringArray[i]=this.stringArray[i].split("");for(var n=0,s=this.stringArray[i];n<s.length;n++)"<"===s[n]&&(this.contentStartEnd[this.contentStartEndIndex]=[],this.contentStartEnd[this.contentStartEndIndex][0]=n),">"===s[n]&&(this.contentStartEnd[this.contentStartEndIndex][1]=n,this.contentStartEndIndex++);for(var r=0;r<this.contentStartEnd.length;r++)for(var a=this.contentStartEnd[r][0];a<this.contentStartEnd[r][1];a++)this.stringArray[i][this.contentStartEnd[r][0]]=this.stringArray[i][this.contentStartEnd[r][0]]+this.stringArray[i][a+1];for(var h=0;h<this.contentStartEnd.length;h++){var o=this.contentStartEnd[h][0]+1;this.stringArray[i].splice(o,this.contentStartEnd[h][1]-this.contentStartEnd[h][0]);for(var p=this.contentStartEnd[h][1]-this.contentStartEnd[h][0],d=0;d<this.contentStartEnd.length;d++)this.contentStartEnd[d][0]=this.contentStartEnd[d][0]-p,this.contentStartEnd[d][1]=this.contentStartEnd[d][1]-p}}},_proto.validateCallbackFunction=function(){"undefined"==typeof this.callback&&(this.callback=function(){return!0})},_proto.randomizeTypeSpeed=function(){this.settings.lifeLike===!0?(this.typeSpeedRangeSpan=this.settings.typeSpeed/2,this.typeSpeedMin=this.settings.typeSpeed-this.typeSpeedRangeSpan,this.typeSpeedMax=this.settings.typeSpeed+this.typeSpeedRangeSpan,this.delayTime=Math.abs(Math.random()*(this.typeSpeedMax-this.typeSpeedMin)+this.typeSpeedMin)):this.delayTime=this.settings.typeSpeed},_proto.typeLoop=function(){this.thisString=this.stringArray[this.stringArrayIndex],this.phraseLength=this.thisString.length,this.typeTimeout=setTimeout(function(){if(this.randomizeTypeSpeed(),this.characterToAppend=this.stringArray[this.stringArrayIndex][this.stringArrayCharacterIndex],-1!==this.characterToAppend.indexOf("<")&&-1===this.characterToAppend.indexOf("</")){this.contentStartEndIndex=0,this.contentStartEnd[0]=this.stringArrayCharacterIndex+1;for(var e=this.stringArrayCharacterIndex;e<this.thisString.length;e++)if(-1!==this.thisString[e].indexOf("</")){this.contentStartEnd[1]=e-1;break}this.contentStartEndSpan=this.contentStartEnd[1]-this.contentStartEnd[0],this.thisTag=t(t.parseHTML(this.characterToAppend)),this.characterToAppend=this.thisTag,this.appendTheCharacter(),this.printingInTag=!0}this.appendTheCharacter(),this.stringArrayCharacterIndex++,this.stringArrayCharacterIndex<this.phraseLength?this.typeLoop():this.stringArray.length>1?(this.stringArrayCharacterIndex=0,this.stringPlaceCount=this.stringPlaceCount+this.phraseLength,this.stringArrayIndex+1===this.stringArray.length?this.endOfStringsFork():this.stringArrayIndex+1<this.stringArray.length&&this.settings.breakLines===!1?setTimeout(function(){this.deleteLoop()}.bind(this),this.settings.breakDelay):this.stringArrayIndex+1<this.stringArray.length&&this.settings.breakLines===!0&&(this.stringArrayIndex++,setTimeout(function(){this.theElement.find(".ti-text-container").removeClass("active-container"),this.theElement.find(".ti-text-container:eq("+this.stringArrayIndex+")").addClass("active-container"),setTimeout(function(){this.typeLoop()}.bind(this),this.settings.breakDelay)}.bind(this),this.settings.breakDelay))):this.endOfStringsFork()}.bind(this),this.delayTime)},_proto.endOfStringsFork=function(){this.settings.loop===!0?setTimeout(function(){this.deleteLoop()}.bind(this),this.settings.loopDelay):this.callback()},_proto.appendTheCharacter=function(){this.settings.breakLines===!0?(this.thisTiTextContainer=this.theElement.find(".ti-text-container:eq("+this.stringArrayIndex+")"),this.thisTiTextContainer.addClass("active-container")):(this.thisTiTextContainer=this.theElement.find(".ti-text-container"),this.thisTiTextContainer.addClass("active-container")),this.appendToHTMLTag(function(){this.thisTiTextContainer.append(this.characterToAppend)}.bind(this))},_proto.appendToHTMLTag=function(e){this.printingInTag===!0?(this.characterToAppend=this.thisString[this.contentStartEnd[0]+this.contentStartEndIndex],t(this.thisTag,this.theElement).last().append(this.characterToAppend),this.printingInTag=this.contentStartEnd[1]===this.contentStartEnd[0]+this.contentStartEndIndex-1?!1:!0,this.contentStartEndIndex++):e()},_proto.deleteLoop=function(t){this.thisTiTextContainer=this.theElement.find(".ti-text-container"),this.deleteTimeout=setTimeout(function(){this.randomizeTypeSpeed(),this.stringToDelete=this.thisTiTextContainer.last().html(),this.arrayToDelete=typeof this.arrayToDelete!==t?this.stringToDelete.split(""):[];for(var e=this.arrayToDelete.length-1;e>-1;e--){if(">"===this.arrayToDelete[e]){for(var i=e-1;i>-1;i--)if("<"===this.arrayToDelete[i]&&">"!==this.arrayToDelete[i-1]){this.arrayToDelete.splice(i-1,1);break}break}this.arrayToDelete.splice(e,1);break}this.thisTiTextContainer.last().html(this.arrayToDelete.join("")),0===this.thisTiTextContainer.last().text().length&&this.thisTiTextContainer.last().html(""),this.thisTiTextContainer.last().text().length>0?this.deleteLoop():this.stringArray[this.stringArrayIndex+1]!==t?(this.stringArrayIndex++,this.typeLoop()):this.settings.loop===!0&&(this.thisTiTextContainer.length>1?(this.thisTiTextContainer.last().remove(),this.theElement.find(".ti-text-container").last().addClass("active-container"),this.deleteLoop()):this.init())}.bind(this),this.delayTime/3)},_proto.stop=function(){clearTimeout(this.typeTimeout),clearTimeout(this.deleteTimeout)}}(jQuery); |
{ | ||
"name": "typeit", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"license": "GPL-2.0", | ||
@@ -16,3 +16,4 @@ "author": "Alex MacArthur <alex@macarthur.me>", | ||
"animated", | ||
"typing" | ||
"typing", | ||
"typewriter" | ||
], | ||
@@ -19,0 +20,0 @@ "main": "dist/typeit.min.js", |
/** | ||
* jQuery TypeIt | ||
* @author Alex MacArthur (http://macarthur.me) | ||
* @version 2.0.1 | ||
* @version 2.0.2 | ||
* @copyright 2016 Alex MacArthur | ||
@@ -128,7 +128,6 @@ * @description Types out a given string or strings. | ||
// if there's a string already typed in the element, replace whatToType with it | ||
if(this.theElement.text().length > 0 && !this.theElement.has('.ti-container')) { | ||
this.settings.whatToType = this.theElement.html(); | ||
if(this.theElement.text().length > 0) { | ||
this.settings.whatToType = this.theElement.text().trim(); | ||
} | ||
}; | ||
@@ -135,0 +134,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1388
215287