useInViewport
A hook to subscribe DOM element visibility change.
API is consistent with ahooks.
Examples
Basic usage
API
const inViewPort = useInViewport(target);
Params
| Property | Description | Type | Default | 
|---|---|---|---|
| target | DOM element or Ref Object | HTMLElement | (() => HTMLElement) | React.MutableRefObject | - | 
Result
| Property | Description | Type | 
|---|---|---|
| inViewPort | Whether DOM elements are in the visible range | boolean |