Prechádzať zdrojové kódy

list: make sure the spinner of infinite scrolling doesn't show on load

When loading a board on a high resolution screen, there is a chance there
is not enough cards displayed and the spinner is still there, spinning
forever.

Add an idle callback that checks if the spinner is still there, and while
it is there, extend the number of cards to show.

Fixes #2250
Benjamin Tissoires 6 rokov pred
rodič
commit
00376b43f8
1 zmenil súbory, kde vykonal 10 pridanie a 3 odobranie
  1. 10 3
      client/components/lists/listBody.js

+ 10 - 3
client/components/lists/listBody.js

@@ -5,6 +5,7 @@ BlazeComponent.extendComponent({
   onCreated() {
   onCreated() {
     // for infinite scrolling
     // for infinite scrolling
     this.cardlimit = new ReactiveVar(InfiniteScrollIter);
     this.cardlimit = new ReactiveVar(InfiniteScrollIter);
+    this.spinnerShown = false;
   },
   },
 
 
   onRendered() {
   onRendered() {
@@ -19,9 +20,8 @@ BlazeComponent.extendComponent({
 
 
       const observer = new IntersectionObserver((entries) => {
       const observer = new IntersectionObserver((entries) => {
         entries.forEach((entry) => {
         entries.forEach((entry) => {
-          if (entry.isIntersecting) {
-            this.cardlimit.set(this.cardlimit.get() + InfiniteScrollIter);
-          }
+          this.spinnerShown = entry.isIntersecting;
+          this.updateList();
         });
         });
       }, options);
       }, options);
 
 
@@ -29,6 +29,13 @@ BlazeComponent.extendComponent({
     }
     }
   },
   },
 
 
+  updateList() {
+    if (this.spinnerShown) {
+      this.cardlimit.set(this.cardlimit.get() + InfiniteScrollIter);
+      window.requestIdleCallback(() => this.updateList());
+    }
+  },
+
   mixins() {
   mixins() {
     return [Mixins.PerfectScrollbar];
     return [Mixins.PerfectScrollbar];
   },
   },