mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 09:41:49 +08:00
PostStream: Fix minor load more issue (#2388)
This commit is contained in:
parent
a2901cef23
commit
03231b2931
|
@ -142,8 +142,6 @@ export default class PostStream extends Component {
|
|||
}
|
||||
|
||||
/**
|
||||
* When the window is scrolled, check if either extreme of the post stream is
|
||||
* in the viewport, and if so, trigger loading the next/previous page.
|
||||
*
|
||||
* @param {Integer} top
|
||||
*/
|
||||
|
@ -154,6 +152,21 @@ export default class PostStream extends Component {
|
|||
|
||||
if (this.stream.pagesLoading) return;
|
||||
|
||||
this.loadPostsIfNeeded(top);
|
||||
|
||||
// Throttle calculation of our position (start/end numbers of posts in the
|
||||
// viewport) to 100ms.
|
||||
clearTimeout(this.calculatePositionTimeout);
|
||||
this.calculatePositionTimeout = setTimeout(this.calculatePosition.bind(this, top), 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if either extreme of the post stream is in the viewport,
|
||||
* and if so, trigger loading the next/previous page.
|
||||
*
|
||||
* @param {Integer} top
|
||||
*/
|
||||
loadPostsIfNeeded(top = window.pageYOffset) {
|
||||
const marginTop = this.getMarginTop();
|
||||
const viewportHeight = $(window).height() - marginTop;
|
||||
const viewportTop = top + marginTop;
|
||||
|
@ -174,11 +187,6 @@ export default class PostStream extends Component {
|
|||
this.stream.loadNext();
|
||||
}
|
||||
}
|
||||
|
||||
// Throttle calculation of our position (start/end numbers of posts in the
|
||||
// viewport) to 100ms.
|
||||
clearTimeout(this.calculatePositionTimeout);
|
||||
this.calculatePositionTimeout = setTimeout(this.calculatePosition.bind(this, top), 100);
|
||||
}
|
||||
|
||||
updateScrubber(top = window.pageYOffset) {
|
||||
|
@ -399,6 +407,8 @@ export default class PostStream extends Component {
|
|||
|
||||
this.calculatePosition();
|
||||
this.stream.paused = false;
|
||||
// Check if we need to load more posts after scrolling.
|
||||
this.loadPostsIfNeeded();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user