|
1 | 1 | # React Is In Viewport
|
2 | 2 |
|
3 |
| -[](https://badge.fury.io/js/react-is-in-viewport) [](https://codecov.io/gh/davidnguyen179/react-is-in-viewport) [](https://travis-ci.com/davidnguyen179/react-is-in-viewport) [](https://greenkeeper.io/) [](https://github.com/davidnguyen179/react-is-in-viewport/blob/master/LICENSE) [](http://makeapullrequest.com) |
| 3 | +<p align="center"> |
| 4 | + <img width="500" alt="fit-overlap" src="https://user-images.githubusercontent.com/6290720/71453121-fa0a1d80-27cc-11ea-9e5f-06a4257fe85e.png" /> |
| 5 | + <br /> |
| 6 | + <br /> |
| 7 | +</p> |
| 8 | + |
| 9 | +The component allows to track the other React components whether or not it is in the Viewport. |
4 | 10 |
|
5 | 11 | <hr />
|
6 | 12 |
|
7 |
| -The component allows to track the other React components whether or not it is in the Viewport. |
| 13 | +[](https://badge.fury.io/js/react-is-in-viewport) [](https://codecov.io/gh/davidnguyen179/react-is-in-viewport) [](https://travis-ci.com/davidnguyen179/react-is-in-viewport) [](https://greenkeeper.io/) [](https://github.com/davidnguyen179/react-is-in-viewport/blob/master/LICENSE) [](http://makeapullrequest.com) [](https://packagequality.com/#?package=react-is-in-viewport) |
| 14 | + |
| 15 | +[](https://packagequality.com/#?package=react-is-in-viewport) |
8 | 16 |
|
9 | 17 | ## Installation
|
10 | 18 |
|
@@ -33,18 +41,17 @@ Here is how `type = 'fit'` and `type = 'overlap'` look like:
|
33 | 41 |
|
34 | 42 | **fit**
|
35 | 43 |
|
36 |
| -<img width="150" alt="Screen Shot 2019-12-22 at 17 10 58" src="https://user-images.githubusercontent.com/6290720/71319400-46a9dc00-24e1-11ea-81ee-85e1bd40ca08.png"> |
| 44 | +<img width="150" alt="fit" src="https://user-images.githubusercontent.com/6290720/71453430-86691000-27ce-11ea-94c7-828e90df09b7.png" /> |
37 | 45 |
|
38 | 46 | **overlap**
|
39 | 47 |
|
40 |
| -<img width="150" alt="Screen Shot 2019-12-22 at 17 11 05" src="https://user-images.githubusercontent.com/6290720/71319410-66d99b00-24e1-11ea-9fe9-96fc68d11aa2.png"> |
41 |
| - |
| 48 | +<img width="150" alt="overlap" src="https://user-images.githubusercontent.com/6290720/71453432-86691000-27ce-11ea-8d28-6130d381a8e1.png"> |
42 | 49 |
|
43 | 50 | ## API
|
44 | 51 |
|
45 | 52 | | Name| Type | Parameter | Description
|
46 | 53 | |--|--|--|--|
|
47 |
| -| onLoad | void | | When component first appears in the viewport | |
| 54 | +| onLoad | void | | When components first appear and fit in the viewport | |
48 | 55 | | onEnter | void | enterCount | When scrolling to a component, the `enterCount` increase 1 |
|
49 | 56 | | onLeave | void | leaveCount | When scrolling away from a component, the `leaveCount` increase 1 |
|
50 | 57 | | onFocusOut | void | focusCount | When component is not in the viewport, then `onFocusOut` called with seconds user spent on the component |
|
@@ -171,3 +178,7 @@ class App extends React.Component {
|
171 | 178 |
|
172 | 179 | ReactDOM.render(<App />, document.getElementById('root'));
|
173 | 180 | ```
|
| 181 | + |
| 182 | +# License |
| 183 | + |
| 184 | +This project is licensed under the MIT License - see the [LICENSE](https://github.com/davidnguyen179/react-is-in-viewport/blob/master/LICENSE) file for details |
0 commit comments