| 83 | } |
| 84 | |
| 85 | append(string) { |
| 86 | const prevString = this.strings[this.strings.length - 1]; |
| 87 | this.strings.push(string); |
| 88 | this.sequence = this.strings.map((_, i) => i); |
| 89 | |
| 90 | // If typing isn't done yet, it will continue with any appended strings |
| 91 | if (!this.typingComplete) return; |
| 92 | |
| 93 | // If typing has completed already, we need to start it up again from where it left off |
| 94 | if (this.shouldBackspace) { |
| 95 | this.timeout = setTimeout(() => { |
| 96 | this.backspace(prevString, prevString.length - 1); |
| 97 | }, this.backDelay); |
| 98 | } else { |
| 99 | this.timeout = setTimeout(() => { |
| 100 | this.arrayPos++; |
| 101 | this.typewrite(this.strings[this.sequence[this.arrayPos]], 0); |
| 102 | }, this.backDelay); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Begins the typing animation |