Skip to content

Commit e341f6e

Browse files
committed
docs(ObserveViewport, connectViewport): add deferUpdateUntilIdle
1 parent 240d687 commit e341f6e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ The optional `recalculateLayoutBeforeUpdate` property, which accepts a function,
118118
In case only certain updates are required `connectViewport` allows an `omit` option to skip updates to `scroll` and `dimensions` events. If both strings are included within the `omit` array, no events will get triggered at all.
119119

120120
``` javascript
121-
const ConnectedComponent = connectViewport({ omit: ['scroll', 'dimensions']})(Component);
121+
const ConnectedComponent = connectViewport({ omit: ['scroll', 'dimensions'] })(Component);
122122
```
123123

124124
The same works for `ObserveViewport` by using the `disableScrollUpdates` and `disableDimensionsUpdates` property.
@@ -131,6 +131,19 @@ The same works for `ObserveViewport` by using the `disableScrollUpdates` and `di
131131
/>
132132
```
133133

134+
### Defer events
135+
136+
Some updates are heavy and might reduce the user experience when scheduled with the same priority as others. Therefore its possible to defer events until idle by enabling `deferUpdateUntilIdle` (default is `false`). If enabled, the `onUpdate` callback/ the rerender of the component will be deferred until no events (independent whether `omit`, `disableDimensionsUpdates` or `disableScrollUpdates` is used) are scheduled anymore.
137+
138+
``` javascript
139+
<ObserveViewport
140+
deferUpdateUntilIdle
141+
onUpdate={handleUpdate}
142+
/>
143+
144+
const ConnectedComponent = connectViewport({ deferUpdateUntilIdle: true })(Component);
145+
```
146+
134147
### ObserveBoundingClientRect
135148

136149
Observes for changes to the bounding client rect of a given reference.

0 commit comments

Comments
 (0)