From ba29b6336e81a7cc2734bba3df3e442f1f68fb57 Mon Sep 17 00:00:00 2001 From: sudheer Date: Fri, 29 Mar 2019 20:56:04 +0530 Subject: [PATCH] Expose virt list scroll variables to window --- components/post_view/post_list.jsx | 8 ++++++-- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/components/post_view/post_list.jsx b/components/post_view/post_list.jsx index 9fe15553b3a2..49dea9b9211b 100644 --- a/components/post_view/post_list.jsx +++ b/components/post_view/post_list.jsx @@ -21,6 +21,9 @@ const POSTS_PER_PAGE = Constants.POST_CHUNK_SIZE / 2; const MAX_NUMBER_OF_AUTO_RETRIES = 3; const MAX_EXTRA_PAGES_LOADED = 10; +const OVERSCAN_COUNT_BACKWARD = window.OVERSCAN_COUNT_BACKWARD || 50; // Exposing the value for PM to test will be removed soon +const OVERSCAN_COUNT_FORWARD = window.OVERSCAN_COUNT_FORWARD || 100; // Exposing the value for PM to test will be removed soon +const HEIGHT_TRIGGER_FOR_MORE_POSTS = window.HEIGHT_TRIGGER_FOR_MORE_POSTS || 1000; // Exposing the value for PM to test will be removed soon export default class PostList extends React.PureComponent { static propTypes = { @@ -297,7 +300,7 @@ export default class PostList extends React.PureComponent { onScroll = ({scrollDirection, scrollOffset, scrollUpdateWasRequested}) => { const isNotLoadingPosts = !this.state.postsLoading && !this.loadingPosts; const didUserScrollBackwards = scrollDirection === 'backward' && !scrollUpdateWasRequested; - const isOffsetWithInRange = scrollOffset < 1000; + const isOffsetWithInRange = scrollOffset < HEIGHT_TRIGGER_FOR_MORE_POSTS; if (isNotLoadingPosts && didUserScrollBackwards && isOffsetWithInRange && !this.state.atEnd) { this.loadingPosts = true; this.loadMorePosts(); @@ -471,7 +474,8 @@ export default class PostList extends React.PureComponent { itemCount={this.state.postListIds.length} itemData={this.state.postListIds} itemKey={this.itemKey} - overscanCount={100} + overscanCountForward={OVERSCAN_COUNT_FORWARD} + overscanCountBackward={OVERSCAN_COUNT_BACKWARD} onScroll={this.onScroll} onItemsRendered={this.onItemsRendered} initScrollToIndex={this.initScrollToIndex} diff --git a/package-lock.json b/package-lock.json index 06b308b3999e..c009f63a9a5a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11993,8 +11993,8 @@ "integrity": "sha512-MYXhTY1BZpdJFjUovvYHVBmkq79szK/k7V3MO+36gJkWGkrXKtyr4vCPtpphaTLRAdDNoYEYFZWE8LjN+PIHNg==" }, "react-window": { - "version": "github:sudheerDev/react-window#ccf30388a1a6a7582e0d0573d4cd24d5776ebbaa", - "from": "github:sudheerDev/react-window#ccf30388a1a6a7582e0d0573d4cd24d5776ebbaa", + "version": "github:sudheerDev/react-window#ac1dd2cae051eddc2c66d3b86b1f551c03397e0a", + "from": "github:sudheerDev/react-window#ac1dd2cae051eddc2c66d3b86b1f551c03397e0a", "requires": { "@babel/runtime": "^7.0.0", "memoize-one": "^3.1.1" diff --git a/package.json b/package.json index b14b682a7a2e..6e4e4dfd45ea 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "react-select": "2.4.1", "react-transition-group": "2.6.0", "react-virtualized-auto-sizer": "^1.0.2", - "react-window": "github:sudheerDev/react-window#ccf30388a1a6a7582e0d0573d4cd24d5776ebbaa", + "react-window": "github:sudheerDev/react-window#ac1dd2cae051eddc2c66d3b86b1f551c03397e0a", "rebound": "0.1.0", "redux": "4.0.1", "redux-batched-actions": "0.4.1",