mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-02 14:49:16 +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:
parent
3565e476c9
commit
efc4ece965
1 changed files with 2 additions and 2 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue