Skip to content

* Fix increasing scrolling error of scrollBy by compensation - #1139

Open
MrRogerHuang wants to merge 22 commits into
futurepress:masterfrom
MrMYHuang:CompensateScrollByError
Open

* Fix increasing scrolling error of scrollBy by compensation#1139
MrRogerHuang wants to merge 22 commits into
futurepress:masterfrom
MrMYHuang:CompensateScrollByError

Conversation

@MrRogerHuang

Copy link
Copy Markdown

`scrollBy' in this file

scrollBy(x, y, silent){

operates scrollLeft or scrollTop for moving to previous or next page.
However, the document
https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft
said: "On systems using display scaling, scrollLeft may give you a decimal value."
Thus, operations on scrollLeft or scrollTop could be not precise!
E.g., this.container.scrollTop is 0 and y is 100, after this.container.scrollTop += y, this.container.scrollTop might become 99.xxx!
The worse problem is this error increases with increasing prev() or next(). It can result in this kind of page shift problem:

With the compensation algorithm in this pull request branch, the problem is alleviated!

This compensation algorithm works also for horizontal writing ePub. E.g, the one without compensation:

The one with compensation:

@felipe-barros

Copy link
Copy Markdown

Hey! Thank you! It worked for me <3

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.

3 participants