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.moveTo
is executed and offset is adjusted. - Looking at
DefaultViewerManager.next
, it executesscrollBy
forthis.layout.delta
in the x direction whenltr
andthis.layout.height
in the y direction whenrtl
andvertical
.epub.js/src/managers/default/index.js
Line 466 in 0963efe
epub.js/src/managers/default/index.js
Line 499 in 0963efe
- On the other hand, for
moveTo
, ifrtl
andvertical
, it executesscrollTo
fordistY = Math.floor(offset.top / this. layout.delta) * this.layout.delta;
epub.js/src/managers/default/index.js
Line 353 in 0963efe
- 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
.
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.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
horizontal
epub,offset.top
<this.layout.delta
always holds anddistY=0
, with no effect.
If this change is considered reasonable I would like to submit a PR. Thank you!
Metadata
Metadata
Assignees
Labels
No labels
Activity