Skip to content

Commit 8eae91b

Browse files
author
Matt Boldt
committed
HTML character typing fixes
1 parent 318f311 commit 8eae91b

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

index.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ <h1 class="h1">Typed.js</h1>
7979

8080
<div class="type-wrap">
8181
<div id="typed-strings">
82-
<p>Typed.js is a <strong>jQuery</strong> plugin.</p>
82+
<p>Typed.js is a <strong><i>jQuery</i></strong> plugin.</p>
8383
<p>It <em>types</em> out sentences.</p>
8484
<p>And then deletes them.</p>
8585
<p>Try it out!</p>

js/typed.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,11 @@
181181
var endTag = '';
182182
if (curChar === '<') {
183183
endTag = '>'
184-
} else {
184+
}
185+
else {
185186
endTag = ';'
186187
}
187-
while (curString.substr(curStrPos).charAt(0) !== endTag) {
188+
while (curString.substr(curStrPos + 1).charAt(0) !== endTag) {
188189
tag += curString.substr(curStrPos).charAt(0);
189190
curStrPos++;
190191
}
@@ -214,11 +215,13 @@
214215
self.timeout = setTimeout(function() {
215216
self.backspace(curString, curStrPos);
216217
}, self.backDelay);
218+
217219
} else {
218220

219221
/* call before functions if applicable */
220-
if (curStrPos === 0)
222+
if (curStrPos === 0) {
221223
self.options.preStringTyped(self.arrayPos);
224+
}
222225

223226
// start typing each new char into existing string
224227
// curString: arg, self.el.html: original text inside element
@@ -278,7 +281,7 @@
278281
// skip over html tags while backspacing
279282
if (curString.substr(curStrPos).charAt(0) === '>') {
280283
var tag = '';
281-
while (curString.substr(curStrPos).charAt(0) !== '<') {
284+
while (curString.substr(curStrPos - 1).charAt(0) !== '<') {
282285
tag -= curString.substr(curStrPos).charAt(0);
283286
curStrPos--;
284287
}

0 commit comments

Comments
 (0)