Explorar el Código

:recycle: storing on component state and setting to footer

tags/0.9.0
J hace 4 años
padre
commit
0affe2e611
Se han modificado 1 ficheros con 8 adiciones y 21 borrados
  1. 8
    21
      vue-theme/src/pages/list.vue

+ 8
- 21
vue-theme/src/pages/list.vue Ver fichero

@@ -48,9 +48,7 @@ export default {
48 48
         return {
49 49
             page: 0,
50 50
             perPage: 6,
51
-            observer: null,
52 51
             keepFetching: true,
53
-            isFetching: false
54 52
         }
55 53
     },
56 54
     computed: {
@@ -148,36 +146,25 @@ export default {
148 146
             const footerEl = document.querySelector(".footer-wrapper footer")
149 147
             // console.warn('attach to: ',footerEl)
150 148
             if(!footerEl) return
151
-            const onIntersect = entries => {
152
-                // if(this.isFetching) return
153
-
154
-                // this.isFetching = true
155
-                entries.forEach(({ target, isIntersecting }) => {
156
-                    if (!isIntersecting) return
157
-                    this.observer.unobserve(target)
158
-                    
159
-                    setTimeout(() => {
160
-                        console.log("intersected:", target)
161
-                    }, 1000)
149
+
150
+            const onIntersect = (entries, observer) => {
151
+                entries.forEach(entry => {
152
+                    if (!entry.isIntersecting) return
153
+                    console.log("intersected:", entry)
162 154
                 })
163
-                // this.isFetching = false
164
-                // this.loadMorePosts()
165
-                // console.log('loaded...', this.loadMorePosts)
166
-                // console.log('cb this:', this)
167 155
             }
168 156
             this.observer = new IntersectionObserver(
169 157
                 onIntersect,
170 158
                 {
171
-                    root: this.$el,
172
-                    threshold: 1.0,
159
+                    root: footerEl,
160
+                    rootMargin: '0px',
161
+                    threshold: 1.0
173 162
                 }
174 163
             )
175
-            this.observer.observe(footerEl)
176 164
         },
177 165
         unsetIntersectionLoader(type) {
178 166
             if(!type) return console.error('cannot unset intersection handler for undefined type...')
179 167
             console.warn('unsetting intersection handler for:', type)
180
-            window.removeEventListener("load", e => {}, false)
181 168
         },
182 169
         clearAndInitPostList() {
183 170
             this.page = 0

Loading…
Cancelar
Guardar