Tweakr
    Preparing search index...

    Function scrollToBottom

    • Scrolls the specified container to the bottom.

      Supports window or any HTMLElement with optional smooth scrolling and offset. Can override scroll height for testing purposes.

      Parameters

      • container: HTMLElement | Window = window

        Scroll container (window or HTMLElement). Defaults to window.

      • behavior: ScrollBehavior = "smooth"

        Scroll behavior: "smooth" or "auto". Defaults to "smooth".

      • offset: number = 0

        Optional offset from bottom. Can be negative. Defaults to 0.

      • OptionalscrollHeight: number

        Optional override for scroll height.

      Returns void

      scrollToBottom(); // Scroll window smoothly to bottom

      const container = document.querySelector("#chat");
      if (container) scrollToBottom(container, "auto", -10); // Scroll a div instantly with offset

      1.2.0