1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-03 14:59:18 +02:00

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
This commit is contained in:
hitode909 2022-12-13 16:40:43 +09:00
parent 3565e476c9
commit efc4ece965

View file

@ -493,9 +493,9 @@ class DefaultViewManager {
this.scrollTop = this.container.scrollTop; 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); this.scrollBy(0, this.layout.height, true);
} else { } else {
next = this.views.last().section.next(); next = this.views.last().section.next();