useInViewport

A hook to subscribe DOM element visibility change.

API is consistent with ahooks.

Examples

Basic usage

API

const inViewPort = useInViewport(target);

Params

PropertyDescriptionTypeDefault
targetDOM element or Ref ObjectHTMLElement | (() => HTMLElement) | React.MutableRefObject-

Result

PropertyDescriptionType
inViewPortWhether DOM elements are in the visible rangeboolean

最近更新: