Skip to content

Commit

Permalink
Expose virt list scroll variables to window (mattermost#2569)
Browse files Browse the repository at this point in the history
  • Loading branch information
sudheerDev authored and saturninoabril committed Mar 30, 2019
1 parent e2a2bd6 commit 4e7715a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions components/post_view/post_list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -299,7 +302,7 @@ export default class PostList extends React.PureComponent {
onScroll = ({scrollDirection, scrollOffset, scrollUpdateWasRequested}) => {
const isNotLoadingPosts = !this.state.loadingFirstSetOfPosts && !this.loadingMorePosts;
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.loadingMorePosts = true;
this.loadMorePosts();
Expand Down Expand Up @@ -473,7 +476,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}
Expand Down

0 comments on commit 4e7715a

Please sign in to comment.