Skip to content

Conversation

hitode909
Copy link

@hitode909 hitode909 commented Dec 13, 2022

Sometime I can't swipe to next chapter on vertical content.
I found that top < this.container.scrollHeight is always true on that broken situation. For example, top is 2199.99 and this.container.scrollHeight is 2200.

let top = this.container.scrollTop + this.container.offsetHeight;
if(top < this.container.scrollHeight) {
this.scrollBy(0, this.layout.height, true);
} else {
next = this.views.last().section.next();

According to MDN, these numbers often have a floating decimal point.

Note: This property will round the value to an integer. If you need a fractional value, use Element.getBoundingClientRect()
Element.scrollHeight - Web APIs | MDN

In my smartphone(Pixel 6a), certainly screen width is 412.19px and screen height is 790.09px.
image

I changed the calculation formula introduced on MDN, it will correctly determine that you have reached the bottom of the container element.

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
@svera
Copy link

svera commented Jan 7, 2023

This solves the problem with continuous mode and certain epub documents. Thank you @hitode909 !

ctlnwng added a commit to Upstatement/epub.js that referenced this pull request Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants