Skip to content

Commit 0b1a5b4

Browse files
authored
Update README.md
1 parent 1a64cb3 commit 0b1a5b4

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,34 @@ import InfiniteScroll from 'react-infinite-scroller';
5656
</div>
5757
```
5858

59+
### Custom parent element
60+
61+
You can define a custom `parentNode` element to base the scroll calulations on.
62+
63+
```
64+
class InfiniteScrollOverride extends InfiniteScroll {
65+
66+
/**
67+
* We are overriding the getParentElement function to use a custom element as the scrollable element
68+
*
69+
* @param {any} el the scroller domNode
70+
* @returns {any} the parentNode to base the scroll calulations on
71+
*
72+
* @memberOf InfiniteScrollOverride
73+
*/
74+
getParentElement(el) {
75+
if (this.props.scrollParent) {
76+
return this.props.scrollParent;
77+
}
78+
return super.getParentElement(el);
79+
}
80+
81+
render() {
82+
return super.render();
83+
}
84+
}
85+
```
86+
5987
## Props
6088

6189
| Name | Type | Default | Description|

0 commit comments

Comments
 (0)