typewriterjs
typewriterjs copied to clipboard
Is there a way to skip the typewriting effect? So if someone wants to not wait just click a button SKIP
I was able to get this working by running .stop()
and using state.elements.wrapper.innerHTML
to fill in the text - here's a snippet of what worked within my application (used currentTypewriter
to store the typewriter and text strings):
let currentTypewriter:{
typewriter: TypewriterClass
text: string
}|null = null
const stopTyping = () => {
if (currentTypewriter) {
const { typewriter, text } = currentTypewriter
const { cursor, wrapper } = typewriter.state.elements
cursor.setAttribute('hidden', 'hidden')
wrapper.innerHTML = text
typewriter.stop()
}
}