use-window-scroll

Subscribe to window scroll and scroll smoothly to given position

Usage

use-window-scroll returns current scroll position and a function to scroll smoothly to given position:

Scroll position x: 0, y: 0

Definition

function useWindowScroll(): readonly [
  { x: number; y: number },
  (position: { x?: number; y?: number }) => void,
];