simple-visual-novel
    Preparing search index...

    Function typewriter

    • Displays text character by character with a typewriter effect.

      The text is revealed one character at a time, creating a typing animation. The returned promise can be cancelled to immediately show the full text.

      Parameters

      • element: HTMLElement

        The DOM element to display text in

      • text: string

        The text to display

      • Optionaloptions: TypewriterOptions = {}

        Typewriter options

        Options for configuring the typewriter text effect.

        TypewriterOptions

        • OptionalonComplete?: () => void

          Callback function invoked when the animation completes (either naturally or when cancelled).

        • Optionalspeed?: number

          Characters per second. Higher values mean faster typing.

      Returns CancellablePromise

      A cancellable promise that resolves when animation completes. Call .cancel() to immediately show the full text.

      const element = document.getElementById("dialogue");
      const animation = typewriter(element, "Hello, world!", { speed: 75 });

      // Optionally cancel to show full text immediately
      animation.cancel();