mirror of
https://github.com/flarum/framework.git
synced 2024-11-22 14:41:39 +08:00
Various iOS scroll improvements (#2548)
* Don't update scrubber while post pages loading This alleviates the scrubber bouncing around when scrolling up on iOS * Throttle loadMore loadPrevious Throttle loadMore and loadPrevious functions to alleviate skipping over pages and pages of posts during one scroll. This sometimes happens on iOS
This commit is contained in:
parent
73a8efaec2
commit
09076e005b
|
@ -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
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { throttle } from 'lodash-es';
|
||||
import anchorScroll from '../../common/utils/anchorScroll';
|
||||
|
||||
class PostStreamState {
|
||||
|
@ -49,6 +50,9 @@ class PostStreamState {
|
|||
*/
|
||||
this.forceUpdateScrubber = false;
|
||||
|
||||
this.loadNext = throttle(this._loadNext, 300);
|
||||
this.loadPrevious = throttle(this._loadPrevious, 300);
|
||||
|
||||
this.show(includedPosts);
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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));
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user