From efc4ece965981987c22ee61daf658f7e3f5a543d Mon Sep 17 00:00:00 2001 From: hitode909 Date: Tue, 13 Dec 2022 16:40:43 +0900 Subject: [PATCH] Improved the bottom reaching detection. These values are floating point in some environments. The scroll position plus the height of the visible area may not exactly match the height of the element. By changing to the calculation formula introduced on MDN, it will correctly determine that you have reached the bottom of the container element. https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#determine_if_an_element_has_been_totally_scrolled --- src/managers/default/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/managers/default/index.js b/src/managers/default/index.js index 2812d87..d23bcd3 100644 --- a/src/managers/default/index.js +++ b/src/managers/default/index.js @@ -493,9 +493,9 @@ class DefaultViewManager { this.scrollTop = this.container.scrollTop; - let top = this.container.scrollTop + this.container.offsetHeight; + const reachedToBottom = Math.abs(this.container.scrollHeight - this.container.clientHeight - this.container.scrollTop) < 1; - if(top < this.container.scrollHeight) { + if(!reachedToBottom) { this.scrollBy(0, this.layout.height, true); } else { next = this.views.last().section.next();