Parcourir la source

:recycle: going back to messy onIntersect

tags/0.9.0
J il y a 4 ans
Parent
révision
a1974e6002
1 fichiers modifiés avec 9 ajouts et 5 suppressions
  1. 9
    5
      vue-theme/src/pages/list.vue

+ 9
- 5
vue-theme/src/pages/list.vue Voir le fichier

@@ -84,9 +84,9 @@ export default {
84 84
             if(!type) return console.error(`type: ${type} not found...`)
85 85
             if(!this.keepFetching) return console.warn('nothing left to fetch...')
86 86
 
87
-            console.warn(`loading page ${this.page} of ${type} posts: ${this.page * this.perPage} through ${this.perPage}`)
88 87
             this.loadingFetched = true
89 88
             this.page++
89
+            console.warn(`loading page ${this.page} of ${type} posts: ${this.page * this.perPage + 1} through ${this.page * this.perPage}`)
90 90
             await this.getPosts()
91 91
         },
92 92
         _getSortBy() {
@@ -152,10 +152,14 @@ export default {
152 152
             const footerEl = document.querySelector(INTERSECT_SELECTION)
153 153
             if(!footerEl) return
154 154
 
155
-            const onIntersect = (entries, observer) => {
156
-                console.log('intersection handler fired...')
157
-                if (this.loadingFetched) return
158
-                setTimeout(this.loadMorePosts(), TIMEOUT)
155
+            const onIntersect = entries => {
156
+                // console.log('intersection handler fired...')
157
+                entries.forEach(entry => {
158
+                    if (!entry.isIntersecting || this.loadingFetched) return
159
+                    setTimeout(() => {
160
+                        this.loadMorePosts()
161
+                    }, TIMEOUT)
162
+                })
159 163
             }
160 164
             this.observer = new IntersectionObserver(onIntersect, {
161 165
                 threshold: 0.80

Chargement…
Annuler
Enregistrer