mirror of
https://github.com/flarum/core.git
synced 2025-07-26 03:01:22 +02:00
PostStream: Fix minor load more issue (#2388)
This commit is contained in:
@@ -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
|
* @param {Integer} top
|
||||||
*/
|
*/
|
||||||
@@ -154,6 +152,21 @@ export default class PostStream extends Component {
|
|||||||
|
|
||||||
if (this.stream.pagesLoading) return;
|
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 marginTop = this.getMarginTop();
|
||||||
const viewportHeight = $(window).height() - marginTop;
|
const viewportHeight = $(window).height() - marginTop;
|
||||||
const viewportTop = top + marginTop;
|
const viewportTop = top + marginTop;
|
||||||
@@ -174,11 +187,6 @@ export default class PostStream extends Component {
|
|||||||
this.stream.loadNext();
|
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) {
|
updateScrubber(top = window.pageYOffset) {
|
||||||
@@ -399,6 +407,8 @@ export default class PostStream extends Component {
|
|||||||
|
|
||||||
this.calculatePosition();
|
this.calculatePosition();
|
||||||
this.stream.paused = false;
|
this.stream.paused = false;
|
||||||
|
// Check if we need to load more posts after scrolling.
|
||||||
|
this.loadPostsIfNeeded();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user