web-api-hooks
Version:
Essential set of React Hooks for convenient Web API consumption.
15 lines (14 loc) • 478 B
TypeScript
/**
* Tracks visual viewport scroll position.
*
* ⚗️ _The underlying technology is experimental. Please be aware about browser compatibility before using this in production._
*
* @returns Coordinates `[x, y]`, falling back to `[0, 0]` when unavailable.
*
* @example
* function Component() {
* const [viewportScrollX, viewportScrollY] = useViewportScrollCoords();
* // ...
* }
*/
export default function useViewportScrollCoords(): Readonly<[number, number]>;