UMD Web Utilities Library
    Preparing search index...

    Function smoothScrollToElement

    • Smoothly scrolls to an element with optional offset and focus management

      Creates an animated scroll to bring the target element into view. After scrolling completes, focuses the element (or its first focusable child). Uses requestAnimationFrame for smooth 60fps animation.

      Parameters

      • element: { element: HTMLElement; frames?: number; spread?: number }

        The element to scroll to

      Returns void

      const section = document.querySelector('#contact');
      smoothScrollToElement({
      element: section,
      spread: 50, // 50px from top
      frames: 45 // Slightly faster scroll
      });