瀏覽代碼

:recycle: simplifying intersection callback

tags/0.9.0
J 4 年之前
父節點
當前提交
7ee7d9e97a
共有 1 個檔案被更改,包括 5 行新增11 行删除
  1. 5
    11
      vue-theme/src/pages/list.vue

+ 5
- 11
vue-theme/src/pages/list.vue 查看文件

@@ -145,23 +145,17 @@ export default {
145 145
             this.$store.commit('SET_HERO', this._setHeroInfo(page))
146 146
         },
147 147
         setIntersectionLoader() {
148
-            if(!this.type) return console.error('cannot setup interseciton handler for undefined type')
148
+            if(!this.type) return console.error('cannot setup intersection handler for undefined type')
149
+            if(this.type == 'episode') return console.warn('intersection handler not setup for episode')
149 150
 
150 151
             console.warn('setting up intersection handler for:', this.type)
151 152
             const footerEl = document.querySelector(INTERSECT_SELECTION)
152
-            // console.warn('found el: ',footerEl)
153 153
             if(!footerEl) return
154
-            // console.warn('attach to: ',footerEl)
155 154
 
156 155
             const onIntersect = (entries, observer) => {
157
-                console.log('intersection handler fired...')
158
-                entries.forEach(entry => {
159
-                    if (!entry.isIntersecting || this.loadingFetched) return
160
-                    console.log("intersected:", entry)
161
-                    setTimeout(() => {
162
-                        this.loadMorePosts()
163
-                    }, 1000)
164
-                })
156
+                // console.log('intersection handler fired...')
157
+                if (this.loadingFetched) return
158
+                setTimeout(this.loadMorePosts, TIMEOUT)
165 159
             }
166 160
             this.observer = new IntersectionObserver(onIntersect, {
167 161
                 threshold: 0.80

Loading…
取消
儲存