From 482bdff3a46542d38fe273dd6801e9c741a21524 Mon Sep 17 00:00:00 2001 From: Cadence Fish Date: Mon, 27 Jan 2020 02:45:50 +1300 Subject: [PATCH] Make pagination threshold more eager --- src/site/html/static/js/pagination.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/site/html/static/js/pagination.js b/src/site/html/static/js/pagination.js index 494687d..63a7673 100644 --- a/src/site/html/static/js/pagination.js +++ b/src/site/html/static/js/pagination.js @@ -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() } }