|
|
@@ -165,7 +165,7 @@ export default {
|
|
165
|
165
|
console.warn('Setting interesection loader...')
|
|
166
|
166
|
|
|
167
|
167
|
// Always unset and reset the intersection loader
|
|
168
|
|
- const footerEl = this.unsetIntersectionLoader()
|
|
|
168
|
+ this.unsetIntersectionLoader()
|
|
169
|
169
|
|
|
170
|
170
|
const onIntersect = (entries, observer) => {
|
|
171
|
171
|
entries.forEach(entry => {
|
|
|
@@ -173,22 +173,23 @@ export default {
|
|
173
|
173
|
setTimeout(() => this.loadMorePosts(), TIMEOUT)
|
|
174
|
174
|
})
|
|
175
|
175
|
}
|
|
176
|
|
- this.observer = new IntersectionObserver(onIntersect, {
|
|
177
|
|
- threshold: 0.80
|
|
178
|
|
- })
|
|
179
|
|
- this.observer['_for_type'] = this.type
|
|
180
|
|
- this.observer.observe(footerEl)
|
|
|
176
|
+ this.observer = new IntersectionObserver(onIntersect, { threshold: 0.80 })
|
|
|
177
|
+ this.observer.observe(document.querySelector(INTERSECT_SELECTOR))
|
|
181
|
178
|
console.log('--- observer')
|
|
182
|
179
|
console.log(this.observer)
|
|
183
|
180
|
},
|
|
184
|
181
|
unsetIntersectionLoader() {
|
|
185
|
182
|
const footerEl = document.querySelector(INTERSECT_SELECTOR)
|
|
186
|
|
- if(!footerEl || !this.observer) return console.error(`cannot unset intersection handler missing el: ${footerEl} or observer: ${this.observer}`)
|
|
187
|
|
-
|
|
188
|
|
- console.warn('unsetting intersection handler on:', footerEl, this.sortBy)
|
|
189
|
|
- this.observer.unobserve(footerEl)
|
|
190
|
|
- this.observer.disconnect()
|
|
191
|
|
- return footerEl
|
|
|
183
|
+ try {
|
|
|
184
|
+ if(!footerEl) throw `cannot unset intersection handler missing el: ${footerEl}`
|
|
|
185
|
+ if(!this.observer) throw `cannot unset intersection handler missing observer: ${this.observer}`
|
|
|
186
|
+
|
|
|
187
|
+ console.warn('unsetting intersection handler on:', footerEl, this.sortBy)
|
|
|
188
|
+ this.observer.unobserve(footerEl)
|
|
|
189
|
+ this.observer.disconnect()
|
|
|
190
|
+ } catch (error) {
|
|
|
191
|
+ console.error(error)
|
|
|
192
|
+ }
|
|
192
|
193
|
},
|
|
193
|
194
|
clearAndInitPostList(caller) {
|
|
194
|
195
|
console.log(`clearAndInitPostList from ${caller}...`)
|