Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When displaying RTL vertical epub with cfi specified, offset is shifted #1271

Open
tjmtmmnk opened this issue Apr 27, 2022 · 0 comments · May be fixed by #1277
Open

When displaying RTL vertical epub with cfi specified, offset is shifted #1271

tjmtmmnk opened this issue Apr 27, 2022 · 0 comments · May be fixed by #1277

Comments

@tjmtmmnk
Copy link

tjmtmmnk commented Apr 27, 2022

Conditions

Problem

Offset is shifted when calling display(cfi).
Screen Shot 2022-04-26 at 18 22 46

Possible Causes

  • When calling display(cfi), DefaultViewManger.display -> DefaultViewManager.moveTo is executed and offset is adjusted.
  • Looking at DefaultViewerManager.next, it executes scrollBy for this.layout.delta in the x direction when ltr and this.layout.height in the y direction when rtl and vertical.
  • On the other hand, for moveTo, if rtl and vertical, it executes scrollTo for distY = Math.floor(offset.top / this. layout.delta) * this.layout.delta;
    • distY = Math.floor(offset.top / this.layout.delta) * this.layout.delta;
    • Therefore, it is not a constant multiple of this.layout.height and is considered to be shifted.

countermeasure

I believe we need to change this.layout.delta in distY = Math.floor(offset.top / this.layout.delta) * this.layout.delta; to this.layout.height.

distY = Math.floor(offset.top / this.layout.delta) * this.layout.delta;
if (distY + this.layout.delta > this.container.scrollHeight) {
distY = this.container.scrollHeight - this.layout.delta;

- distY = Math.floor(offset.top / this.layout.delta) * this.layout.delta;
- if (distY + this.layout.delta > this.container.scrollHeight) {
-  distY = this.container.scrollHeight - this.layout.delta;
}

+ distY = Math.floor(offset.top / this.layout.height) * this.layout.height;
+ if (distY + this.layout.height > this.container.scrollHeight) {
+   distY = this.container.scrollHeight - this.layout.height;
}

Results of measures

before after
before after
  • Confirmed that the offset shift was gone.
  • I also confirmed that for horizontal epub, offset.top < this.layout.delta always holds and distY=0, with no effect.

If this change is considered reasonable I would like to submit a PR. Thank you!

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 a pull request may close this issue.

1 participant