Skip to content

Commit e42bffe

Browse files
committed
Reset view whenever children change
1 parent de9db41 commit e42bffe

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/index.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@ export default class GradientScroll extends Component {
1919
this.handleScroll();
2020
}
2121

22+
componentDidUpdate(prevProps) {
23+
if (prevProps.children !== this.props.children) {
24+
this.handleScroll();
25+
}
26+
}
27+
2228
handleScroll = () => {
2329
const scrollableScrollTop = this.scrollableElement.scrollTop;
24-
const scrollableHeight = this.scrollableElement.clientHeight;
2530
const contentHeight = this.contentElement.clientHeight;
26-
const diff = scrollableScrollTop - contentHeight;
2731
const atBottom = this.scrollableElement.scrollHeight === contentHeight + scrollableScrollTop;
2832
const overlayClasses = [];
2933
if (scrollableScrollTop === 0) {

0 commit comments

Comments
 (0)