Skip to content

Commit 1f03482

Browse files
committed
Improve the readme
1 parent cc7ff6d commit 1f03482

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ reports
55
example
66
lib/
77
es/
8+
coverage/
89
nuget
910
npm-debug.log*
1011
.DS_store
@@ -13,4 +14,4 @@ npm-debug.log*
1314
.idea
1415
.tern
1516
.tmp
16-
*.log
17+
*.log

README.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ or NPM:
2525
npm install react-intersection-observer --save
2626
```
2727

28+
> You also want to add the [intersection-observer](https://www.npmjs.com/package/react-intersection-observer) polyfill for full browser support. Check out adding the [polyfill](#polyfill) for details.
29+
2830
## Usage
2931

3032
### Child as function
@@ -69,7 +71,7 @@ export default Component
6971
### OnChange callback
7072

7173
You can monitor the onChange method, and control the state in your own
72-
component.
74+
component. This works with plain children, child as function or render props.
7375

7476
```js
7577
import Observer from 'react-intersection-observer'
@@ -99,25 +101,28 @@ The **`<Observer />`** accepts the following props:
99101
| **triggerOnce** | Bool | false | false | Only trigger this method once |
100102
| **onChange** | Func | | false | Call this function whenever the in view state changes |
101103

104+
## Usage in other projects
102105

103-
## Scroll monitor
106+
### react-scroll-percentage
104107

105108
This module is used in
106109
[react-scroll-percentage](https://github.com/thebuilder/react-scroll-percentage)
107-
to monitor the scroll position of elements in view. This module is also a great
108-
example of using `react-intersection-observer` as the basis for more complex
109-
needs.
110+
to monitor the scroll position of elements in view, useful for animating items as
111+
they become visible. This module is also a great example of using `react-intersection-observer`
112+
as the basis for more complex needs.
113+
114+
## Intersection Observer
115+
116+
[Intersection Observer](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)
117+
is the API is used to determine if an element is inside the viewport or not. Browser support is pretty good, but Safari is still missing support.
110118

111-
## Polyfill for intersection-observer
119+
> [Can i use intersectionobserver?](https://caniuse.com/#feat=intersectionobserver)
112120
113-
The component requires the [intersection-observer
114-
API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)
115-
to be available on the global namespace. At the moment you should include a
116-
polyfill to ensure support in all browsers.
121+
### Polyfill
117122

118123
You can import the
119-
[polyfill](https://yarnpkg.com/en/package/intersection-observer) directly or use
120-
a service like [polyfill.io](https://polyfill.io/v2/docs/) that can add it when
124+
[polyfill](https://www.npmjs.com/package/react-intersection-observer) directly or use
125+
a service like [polyfill.io](https://polyfill.io/v2/docs/) to add it when
121126
needed.
122127

123128
```sh

0 commit comments

Comments
 (0)