Skip to content

Commit d91ab3d

Browse files
Daniel Schmidtthebuilder
authored andcommitted
Add rootID and refactor intersection.js
1 parent a52534f commit d91ab3d

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,17 @@ import 'intersection-observer'
5151
## Props
5252
The **`<Observer />`** accepts the following props:
5353

54-
| Name | Type | Default | Required | Description |
55-
| ---------------- | --------- | ----------------- | -------- | ----------------------------------------------------- |
56-
| children | func/node | | true | Children should be either a function or a node |
57-
| tag | String | | false | Element tag to use for the wrapping component |
58-
| threshold | Number | 0 | false | Number between 0 and 1 indicating the the percentage that should be visible before triggering |
59-
| triggerOnce | Bool | false | false | Only trigger this method once |
60-
| onChange | Func | | false | Call this function whenever the in view state changes |
61-
| render | Func | | false | Use render method to only render content when inView |
54+
| Name | Type | Default | Required | Description |
55+
| ---------------- | ----------- | ----------------- | -------- | ----------------------------------------------------- |
56+
| children | func/node | | true | Children should be either a function or a node |
57+
| 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. |
58+
| 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. |
59+
| 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). |
60+
| tag | String | 'div' | false | Element tag to use for the wrapping component |
61+
| 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. |
62+
| triggerOnce | Bool | false | false | Only trigger this method once |
63+
| onChange | Func | | false | Call this function whenever the in view state changes |
64+
| render | Func | | false | Use render method to only render content when inView |
6265

6366
## Example code
6467

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Observer extends Component {
2121
children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
2222
/** Only trigger the inView callback once */
2323
triggerOnce: PropTypes.bool,
24-
/** Number between 0 and 1 indicating the the percentage that should be visible before triggering */
24+
/** 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. */
2525
threshold: PropTypes.oneOfType([
2626
PropTypes.arrayOf(PropTypes.number),
2727
PropTypes.number,

0 commit comments

Comments
 (0)