Skip to content

Commit

Permalink
MM-14791 Safari and FF takes an extra frame for scroll correction cau…
Browse files Browse the repository at this point in the history
…sing jump to the right post when loading more posts (mattermost#2556)
  • Loading branch information
sudheerDev authored Mar 28, 2019
1 parent 9a6a29f commit 742f772
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 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 @@ -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();
Expand Down Expand Up @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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#e1c298a26c7db32253ba332bc2057dd242d5d8cd",
"rebound": "0.1.0",
"redux": "4.0.1",
"redux-batched-actions": "0.4.1",
Expand Down

0 comments on commit 742f772

Please sign in to comment.