You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: implement useHooks and update rollup config (#136)
* feat: implement useHooks and update rollup config
This commit implements the new Hook API, and also improves the Rollup build output
* docs: work on the readme
* chore: upgrade dependencies - upgrade npm-run-all
No more flatmap-stream
* refactor: update the typescript definition
Copy file name to clipboardExpand all lines: README.md
+93-38Lines changed: 93 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,81 +31,128 @@ or NPM:
31
31
npm install react-intersection-observer --save
32
32
```
33
33
34
-
> ⚠️ 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 about how you can include it.
|**root**| HTMLElement || false | The HTMLElement that is used as the viewport for checking visibility of the target. Defaults to the browser viewport if not specified or if null. |
127
+
|**rootId**| String || false | Unique identifier for the root element - This is used to identify the IntersectionObserver instance, so it can be reused. If you defined a root element, without adding an id, it will create a new instance for all components. |
128
+
|**rootMargin**| String | '0px' | false | Margin around the root. Can have values similar to the CSS margin property, e.g. "10px 20px 30px 40px" (top, right, bottom, left). |
129
+
|**threshold**| Number | 0 | false | Number between 0 and 1 indicating the the percentage that should be visible before triggering. Can also be an array of numbers, to create multiple trigger points. |
130
+
|**triggerOnce**| Bool | false | false | Only trigger this method once |
80
131
81
-
## Props
132
+
### InView Props
82
133
83
-
The **`<Observer />`** accepts the following props:
134
+
The **`<InView />`** component also accepts the following props:
84
135
85
-
| Name | Type | Default | Required | Description |
|**children**| ({inView, ref}) => React.Node / React.Node || true | Children expects a function that receives an object contain an `inView` boolean and `ref` that should be assigned to the element root. Alternately pass a plain child, to have the `<Observer />` deal with the wrapping element. |
88
-
|**onChange**| (inView) => void || false | Call this function whenever the in view state changes |
89
-
|**root**| HTMLElement || false | The HTMLElement that is used as the viewport for checking visibility of the target. Defaults to the browser viewport if not specified or if null. |
90
-
|**rootId**| String || false | Unique identifier for the root element - This is used to identify the IntersectionObserver instance, so it can be reused. If you defined a root element, without adding an id, it will create a new instance for all components. |
91
-
|**rootMargin**| String | '0px' | false | Margin around the root. Can have values similar to the CSS margin property, e.g. "10px 20px 30px 40px" (top, right, bottom, left). |
92
-
|**threshold**| Number | 0 | false | Number between 0 and 1 indicating the the percentage that should be visible before triggering. Can also be an array of numbers, to create multiple trigger points. |
93
-
|**triggerOnce**| Bool | false | false | Only trigger this method once |
136
+
| Name | Type | Default | Required | Description |
|**children**| ({inView, ref}) => React.Node / React.Node || true | Children expects a function that receives an object contain an `inView` boolean and `ref` that should be assigned to the element root. Alternately pass a plain child, to have the `<Observer />` deal with the wrapping element. |
139
+
|**onChange**| (inView) => void || false | Call this function whenever the in view state changes |
0 commit comments