1
0
mirror of https://git.sr.ht/~cadence/bibliogram synced 2024-11-22 08:07:30 +00:00

Make pagination threshold more eager

This commit is contained in:
Cadence Fish 2020-01-27 02:45:50 +13:00
parent 59d891b94b
commit 482bdff3a4
No known key found for this signature in database
GPG Key ID: 81015DF9AA8607E1

View File

@ -13,6 +13,8 @@ class FreezeWidth extends ElemJS {
}
}
const intersectionThreshold = 0
class NextPage extends FreezeWidth {
constructor(container) {
super(container)
@ -21,7 +23,7 @@ class NextPage extends FreezeWidth {
this.attribute("href", "javascript:void(0)")
this.event("click", event => this.onClick(event))
this.observer = new IntersectionObserver(entries => this.onIntersect(entries), {rootMargin: "-20px", threshold: 1})
this.observer = new IntersectionObserver(entries => this.onIntersect(entries), {rootMargin: "0px", threshold: intersectionThreshold})
this.observer.observe(this.element)
}
@ -44,7 +46,7 @@ class NextPage extends FreezeWidth {
* @param {IntersectionObserverEntry[]} entries
*/
onIntersect(entries) {
if (entries.some(entry => entry.isIntersecting && entry.intersectionRatio == 1)) this.onClick()
if (entries.some(entry => entry.isIntersecting && entry.intersectionRatio >= intersectionThreshold)) this.onClick()
}
}