Skip to content

Commit dcab25a

Browse files
committed
feat: add readme
1 parent f10f8db commit dcab25a

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## use-in-viewport
2+
3+
**React hook for check if the current element in viewport.**
4+
5+
**Author**
6+
7+
- name: _Martik Avagyan_
8+
- email: _<martikavagyan1@gmail.com>_
9+
- github: _[m-avagyan](https://github.com/m-avagyan)_
10+
11+
## Getting started
12+
13+
**Installation**
14+
15+
`npm install use-in-viewport` or `yarn add use-in-viewport`
16+
17+
**Example**
18+
19+
```javascript
20+
import React, { useRef } from 'react';
21+
import useInViewport from 'use-in-viewport';
22+
23+
function Example() {
24+
const elementRef = useRef(null);
25+
const inViewport = useInViewport(elementRef);
26+
27+
return (
28+
<div ref={inViewport}>
29+
Element is {inViewport ? 'in viewport' : 'not in viewport'}
30+
</div>
31+
);
32+
}
33+
34+
export default Example;
35+
```
36+
37+
---
38+
39+
**Copyright (c) 2022 [Martik Avagyan](https://github.com/m-avagyan)**

0 commit comments

Comments
 (0)