MCPcopy
hub / github.com/mattboldt/typed.js / append

Method append

src/typed.js:85–104  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

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

Callers 1

demos.jsFile · 0.80

Calls 2

backspaceMethod · 0.95
typewriteMethod · 0.95

Tested by

no test coverage detected