tameemsafi / typewriterjs

A simple yet powerful native javascript plugin for a cool typewriter effect.
https://www.npmjs.com/package/typewriter-effect
MIT License
2.49k stars 221 forks source link

Change cursor when done typing. #191

Closed mkabatek closed 1 year ago

mkabatek commented 1 year ago

It would be nice if there was a way to change or stop the cursor from blinking when done typing.

qwerty084 commented 1 year ago

Same problem, would be nice to have a method to remove/hide it.

As a workaround you could just remove the cursor element, after the text has been written.


new Typewriter('#typewriter', {
    strings: message,
    autoStart: true,
    delay: 30,
  }).callFunction(() => {
    document.querySelector(".Typewriter__cursor").remove();
  });
dmackerman commented 1 year ago

Thanks @qwerty084

tameemsafi commented 1 year ago

You can use the changeCursor method to change the cursor to an empty string

Lejio commented 1 year ago

For those wondering how to do this in react:

      <TypewriterComponent
        options={{
          autoStart: true,
        }}
        onInit={(typewriter) => {
          typewriter.typeString("Hello I am <insert name>").callFunction((state) => {
            state.elements.cursor.remove();
          });
        }}
      />