-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
84 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "typed.js", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"homepage": "https://github.com/mattboldt/typed.js", | ||
"authors": [ | ||
"Matt Boldt <[email protected]>" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* | ||
* typed.js - A JavaScript Typing Animation Library | ||
* Author: Matt Boldt <[email protected]> | ||
* Version: v2.0.1 | ||
* Version: v2.0.3 | ||
* Url: https://github.com/mattboldt/typed.js | ||
* License(s): MIT | ||
* | ||
|
@@ -215,6 +215,7 @@ return /******/ (function(modules) { // webpackBootstrap | |
} | ||
|
||
var humanize = this.humanizer(this.typeSpeed); | ||
var numChars = 1; | ||
|
||
if (this.pause.status === true) { | ||
this.setPauseStatus(curString, curStrPos, true); | ||
|
@@ -223,27 +224,42 @@ return /******/ (function(modules) { // webpackBootstrap | |
|
||
// contain typing function in a timeout humanize'd delay | ||
this.timeout = setTimeout(function () { | ||
// skip over any HTML chars | ||
curStrPos = _htmlParserJs.htmlParser.typeHtmlChars(curString, curStrPos, _this2); | ||
|
||
var pauseTime = 0; | ||
var substr = curString.substr(curStrPos); | ||
// check for an escape character before a pause value | ||
// format: \^\d+ .. eg: ^1000 .. should be able to print the ^ too using ^^ | ||
// single ^ are removed from string | ||
var pauseTime = 0; | ||
var substr = curString.substr(curStrPos); | ||
if (substr.charAt(0) === '^') { | ||
var skip = 1; // skip atleast 1 | ||
if (/^\^\d+/.test(substr)) { | ||
var skip = 1; // skip at least 1 | ||
substr = /\d+/.exec(substr)[0]; | ||
skip += substr.length; | ||
pauseTime = parseInt(substr); | ||
_this2.temporaryPause = true; | ||
_this2.options.onTypingPaused(_this2.arrayPos, _this2); | ||
// strip out the escape character and pause value so they're not printed | ||
curString = curString.substring(0, curStrPos) + curString.substring(curStrPos + skip); | ||
_this2.toggleBlinking(true); | ||
} | ||
_this2.toggleBlinking(true); | ||
|
||
// strip out the escape character and pause value so they're not printed | ||
curString = curString.substring(0, curStrPos) + curString.substring(curStrPos + skip); | ||
} | ||
|
||
curStrPos = _htmlParserJs.htmlParser.typeHtmlChars(curString, curStrPos, _this2); | ||
// check for skip characters formatted as | ||
// "this is a `string to print NOW` ..." | ||
if (substr.charAt(0) === '`') { | ||
while (curString.substr(curStrPos + numChars).charAt(0) !== '`') { | ||
numChars++; | ||
if (curStrPos + numChars > curString.length) break; | ||
} | ||
// strip out the escape characters and append all the string in between | ||
var stringBeforeSkip = curString.substring(0, curStrPos); | ||
var stringSkipped = curString.substring(stringBeforeSkip.length + 1, curStrPos + numChars); | ||
var stringAfterSkip = curString.substring(curStrPos + numChars + 1); | ||
curString = stringBeforeSkip + stringSkipped + stringAfterSkip; | ||
numChars--; | ||
} | ||
|
||
// timeout for any pause after a character | ||
_this2.timeout = setTimeout(function () { | ||
|
@@ -254,7 +270,7 @@ return /******/ (function(modules) { // webpackBootstrap | |
if (curStrPos === curString.length) { | ||
_this2.doneTyping(curString, curStrPos); | ||
} else { | ||
_this2.keepTyping(curString, curStrPos); | ||
_this2.keepTyping(curString, curStrPos, numChars); | ||
} | ||
// end of character pause | ||
if (_this2.temporaryPause) { | ||
|
@@ -275,18 +291,17 @@ return /******/ (function(modules) { // webpackBootstrap | |
*/ | ||
}, { | ||
key: 'keepTyping', | ||
value: function keepTyping(curString, curStrPos) { | ||
value: function keepTyping(curString, curStrPos, numChars) { | ||
// call before functions if applicable | ||
if (curStrPos === 0) { | ||
this.toggleBlinking(false); | ||
this.options.preStringTyped(this.arrayPos, this); | ||
} | ||
// start typing each new char into existing string | ||
// curString: arg, this.el.html: original text inside element | ||
var nextString = curString.substr(0, curStrPos + 1); | ||
curStrPos += numChars; | ||
var nextString = curString.substr(0, curStrPos); | ||
this.replaceText(nextString); | ||
// add characters one by one | ||
curStrPos++; | ||
// loop the function | ||
this.typewrite(curString, curStrPos); | ||
} | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters