typewriterjs
typewriterjs copied to clipboard
React 'Loop:false' Erase the content at the end:
Hi. Thanks a lot for the awesome library.
Actually, I am facing a problem with the react component.
If My loop is set to false, the content will get erased at the end.
<Typewriter options={{ strings: ['Hi,'], autoStart: true, }} />
Here the Hi will get eased after getting typed.
I would have been Nice if the content stayed where it should be when the function ends.
PS: It actually works properly when I am passing the values in onInit method to the component
<Typewriter onInit={(typewriter) => { typewriter.typeString('Hi,') .start(); }} />
I have the exact same issue. By looking at the code, e.g. this line it turns out that it iterates over all strings provided via options with type, pause, delete.
this.options.strings.forEach(string => {
this.typeString(string)
.pauseFor(this.options.pauseFor)
.deleteAll(this.options.deleteSpeed);
});
A quick fix which worked for me is the following:
<Typewriter
onInit={typewriter => {
messages.slice(0, messages.length - 1).forEach(message => {
typewriter.typeString(message).pauseFor(1000).deleteAll()
})
typewriter
.typeString(messages[messages.length - 1])
.pauseFor(1000)
.start()
}}
/>
Having the same problem - this library always deletes the text after it renders for some reason. There doesn't seem to be an option to disable that behavior which makes it totally useless for most use cases.