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
|**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 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 |
130
+
| Name | Type | Default | Required | Description |
|**root**| Element || false | The Element that is used as the viewport for checking visibility of the target. Defaults to the browser viewport (`window`) if not specified or if null. |
133
+
|**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). |
134
+
|**threshold**| Number \| number[]| 0 | false | Number between 0 and 1 indicating the percentage that should be visible before triggering. Can also be an array of numbers, to create multiple trigger points. |
135
+
|**triggerOnce**| Bool | false | false | Only trigger this method once |
131
136
132
137
### InView Props
133
138
134
139
The **`<InView />`** component also accepts the following props:
135
140
136
-
| Name | Type | Default | Required | Description |
|**children**| ({inView, intersectionRatio, 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. You also receive the last `intersectionRatio`|
139
-
|**onChange**| (inView, intersectionRatio) => void || false | Call this function whenever the in view state changes |
141
+
| Name | Type | Default | Required | Description |
|**children**|`({inView, intersection, ref}) => React.Node` or `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. You will also get the `IntersectionObserverEntry` as `intersection, giving you more details.|
144
+
|**onChange**|`(inView, intersection) => void`|| false | Call this function whenever the in view state changes|
140
145
141
146
## Usage in other projects
142
147
@@ -179,28 +184,13 @@ the Polyfill only if needed. A basic implementation could look something like
179
184
this:
180
185
181
186
```js
182
-
loadPolyfills()
183
-
.then(() =>/* Render React application now that your Polyfills are ready */)
184
-
185
187
/**
186
-
* Do feature detection, to figure out which polyfills needs to be imported.
187
-
**/
188
-
functionloadPolyfills() {
189
-
constpolyfills= []
190
-
191
-
if (!supportsIntersectionObserver()) {
192
-
polyfills.push(import('intersection-observer'))
188
+
* Do feature detection, to figure out which polyfills needs to be imported.
189
+
**/
190
+
asyncfunctionloadPolyfills() {
191
+
if (typeofwindow.IntersectionObserver==='undefined') {
0 commit comments