Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various iOS scroll improvements #2548

Merged
merged 3 commits into from Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions js/src/forum/components/PostStream.js
Expand Up @@ -146,12 +146,10 @@ export default class PostStream extends Component {
* @param {Integer} top
*/
onscroll(top = window.pageYOffset) {
if (this.stream.paused) return;
if (this.stream.paused || this.stream.pagesLoading) return;

this.updateScrubber(top);

if (this.stream.pagesLoading) return;

this.loadPostsIfNeeded(top);

// Throttle calculation of our position (start/end numbers of posts in the
Expand Down
8 changes: 6 additions & 2 deletions js/src/forum/states/PostStreamState.js
@@ -1,3 +1,4 @@
import { throttle } from 'lodash-es';
import anchorScroll from '../../common/utils/anchorScroll';

class PostStreamState {
Expand Down Expand Up @@ -49,6 +50,9 @@ class PostStreamState {
*/
this.forceUpdateScrubber = false;

this.loadNext = throttle(this._loadNext, 300);
this.loadPrevious = throttle(this._loadPrevious, 300);

this.show(includedPosts);
}

Expand Down Expand Up @@ -187,7 +191,7 @@ class PostStreamState {
/**
* Load the next page of posts.
*/
loadNext() {
_loadNext() {
const start = this.visibleEnd;
const end = (this.visibleEnd = this.sanitizeIndex(this.visibleEnd + this.constructor.loadCount));

Expand All @@ -210,7 +214,7 @@ class PostStreamState {
/**
* Load the previous page of posts.
*/
loadPrevious() {
_loadPrevious() {
const end = this.visibleStart;
const start = (this.visibleStart = this.sanitizeIndex(this.visibleStart - this.constructor.loadCount));

Expand Down