aboutsummaryrefslogtreecommitdiff
path: root/p/scripts
diff options
context:
space:
mode:
authorGravatar Frans de Jonge <fransdejonge@gmail.com> 2023-11-04 17:49:48 +0100
committerGravatar GitHub <noreply@github.com> 2023-11-04 17:49:48 +0100
commitecf1585d74c44954720acddce02d3827c93a06df (patch)
tree00ad1810e18e244008efc51cbbd4222ace382ea6 /p/scripts
parenta4dc348c3d65ea0e99d62381342b9a19ee2125cd (diff)
init_posts(): load more posts on window resize (#5815)
* init_posts(): load more posts on window resize Fixes: 1. Open FreshRSS in a shorter window 2. Resize to be much longer 3. Half the window remains empty This is most obviously a problem on vertical monitors. * Address comments * blah blah * typo
Diffstat (limited to 'p/scripts')
-rw-r--r--p/scripts/main.js25
1 files changed, 14 insertions, 11 deletions
diff --git a/p/scripts/main.js b/p/scripts/main.js
index 42d7aeef4..4ddafb2bd 100644
--- a/p/scripts/main.js
+++ b/p/scripts/main.js
@@ -735,20 +735,23 @@ function onScroll() {
}
}
+let lastScroll = 0; // Throttle
+let timerId = 0;
+function debouncedOnScroll() {
+ clearTimeout(timerId);
+ if (lastScroll + 500 < Date.now()) {
+ lastScroll = Date.now();
+ onScroll();
+ } else {
+ timerId = setTimeout(onScroll, 500);
+ }
+}
+
function init_posts() {
if (context.auto_load_more || context.auto_mark_scroll || context.auto_remove_article) {
box_to_follow = context.current_view === 'global' ? document.getElementById('panel') : document.scrollingElement;
- let lastScroll = 0; // Throttle
- let timerId = 0;
- (box_to_follow === document.scrollingElement ? window : box_to_follow).onscroll = function () {
- clearTimeout(timerId);
- if (lastScroll + 500 < Date.now()) {
- lastScroll = Date.now();
- onScroll();
- } else {
- timerId = setTimeout(onScroll, 500);
- }
- };
+ (box_to_follow === document.scrollingElement ? window : box_to_follow).onscroll = debouncedOnScroll;
+ window.addEventListener('resize', debouncedOnScroll);
onScroll();
}