From 3ec39ee7c9a5fdf1246effaaff8470c5c8c0f60a Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Thu, 18 Jul 2019 23:55:32 -0400 Subject: [PATCH] Updated scrollable list to improve infinite scoll --- app/javascript/gabsocial/components/scrollable_list.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/javascript/gabsocial/components/scrollable_list.js b/app/javascript/gabsocial/components/scrollable_list.js index 1dbbdb23..c526f5f7 100644 --- a/app/javascript/gabsocial/components/scrollable_list.js +++ b/app/javascript/gabsocial/components/scrollable_list.js @@ -82,7 +82,7 @@ export default class ScrollableList extends PureComponent { componentDidMount () { this.window = window; - this.documentElement = document.documentElement; + this.documentElement = document.scrollingElement || document.documentElement; this.attachScrollListener(); this.attachIntersectionObserver(); @@ -124,10 +124,11 @@ export default class ScrollableList extends PureComponent { handleScroll = throttle(() => { if (this.window) { - const { scrollTop, scrollHeight, clientHeight } = this.documentElement; - const offset = scrollHeight - scrollTop - clientHeight; + const { scrollTop, scrollHeight } = this.documentElement; + const { innerHeight } = this.window; + const offset = scrollHeight - scrollTop - innerHeight; - if (600 > offset && this.props.onLoadMore && this.props.hasMore && !this.props.isLoading) { + if (400 > offset && this.props.onLoadMore && this.props.hasMore && !this.props.isLoading) { this.props.onLoadMore(); } @@ -174,6 +175,7 @@ export default class ScrollableList extends PureComponent { componentWillUnmount () { this.clearMouseIdleTimer(); + this.detachScrollListener(); this.detachIntersectionObserver(); }