-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Description
Conditions
- confirmed this problem with
examples/locations.html.- This is my code. https://gist.github.com/tjmtmmnk/87742bc8106a89ab3d018b28f341eb86
- checked using the epub "Vertical Writing" provided on this site. http://idpf.github.io/epub3-samples/30/samples.html
- checked by pixel5 on the developer tools
Problem
Offset is shifted when calling display(cfi).

Possible Causes
- When calling
display(cfi),DefaultViewManger.display->DefaultViewManager.moveTois executed and offset is adjusted. - Looking at
DefaultViewerManager.next, it executesscrollByforthis.layout.deltain the x direction whenltrandthis.layout.heightin the y direction whenrtlandvertical.epub.js/src/managers/default/index.js
Line 466 in 0963efe
this.scrollBy(this.layout.delta, 0, true); epub.js/src/managers/default/index.js
Line 499 in 0963efe
this.scrollBy(0, this.layout.height, true);
- On the other hand, for
moveTo, ifrtlandvertical, it executesscrollTofordistY = Math.floor(offset.top / this. layout.delta) * this.layout.delta;epub.js/src/managers/default/index.js
Line 353 in 0963efe
distY = Math.floor(offset.top / this.layout.delta) * this.layout.delta; - Therefore, it is not a constant multiple of
this.layout.heightand 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.
epub.js/src/managers/default/index.js
Lines 353 to 356 in 0963efe
| 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 |
|---|---|
![]() |
![]() |
- Confirmed that the offset shift was gone.
- I also confirmed that for
horizontalepub,offset.top<this.layout.deltaalways holds anddistY=0, with no effect.
If this change is considered reasonable I would like to submit a PR. Thank you!
AmenZhou and yarnie046
Metadata
Metadata
Assignees
Labels
No labels

