@wbe/use-is-in-viewport
TypeScript icon, indicating that this package has built-in type declarations

2.3.0 • Public • Published

@wbe/use-is-in-viewport

This React hook allow to check if a specific ref element is visible in viewport.

Installation

$ npm install -s @wbe/use-is-in-viewport

How to use

import { useIsInViewport } from "@wbe/use-is-in-viewport;";

// Get element ref
const ref = useRef(null);

// Check if is in viewport (hook return boolean)
const isInViewport = useIsInViewport(ref);

return <div ref={ref} />;

Parameters

params type description default value
pRef MutableRefObject element ref /
pToogleVisibility boolean Repeat the check visibility even if ref element visibility is already passed to true false
pOffset number Define a positive or negative offset to the ref element 0

Returned

Hook return a boolean.

Readme

Keywords

Package Sidebar

Install

npm i @wbe/use-is-in-viewport

Weekly Downloads

1

Version

2.3.0

License

MIT

Unpacked Size

38.5 kB

Total Files

16

Last publish

Collaborators

  • willybe