@owaiswiz/use-in-view
Version:
Check if your component is in viewport using this simple hook!
35 lines (25 loc) • 993 B
Markdown
## useInView
Check if your component is in viewport using this simple hook!
[](https://travis-ci.org/elinadenfina/useInView)
[](https://github.com/prettier/prettier)



⭐ ⭐ Check out a working demo [here](https://elinadenfina.github.io/useInView/) ⭐ ⭐
## Install
```
$ yarn add use-in-view
```
## Usage
```jsx
import useInView from 'use-in-view';
const AnimatedComponent = () => {
const offset = 30;
const [ref, inView] = useInView(offset);
return (
<div className={`${inView && 'in-view'}`} ref={ref}>
Animate me!
</div>
);
};
```