mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-02 14:49:16 +02:00
add RTL support for moveTo function
fixes links in RTL books
This commit is contained in:
parent
a1e77b745b
commit
1e5c12c9bd
1 changed files with 14 additions and 3 deletions
|
@ -277,7 +277,8 @@ class DefaultViewManager {
|
|||
|
||||
if(target) {
|
||||
let offset = visible.locationOf(target);
|
||||
this.moveTo(offset);
|
||||
let width = visible.width();
|
||||
this.moveTo(offset, width);
|
||||
}
|
||||
|
||||
displaying.resolve();
|
||||
|
@ -298,7 +299,8 @@ class DefaultViewManager {
|
|||
// Move to correct place within the section, if needed
|
||||
if(target) {
|
||||
let offset = view.locationOf(target);
|
||||
this.moveTo(offset);
|
||||
let width = view.width();
|
||||
this.moveTo(offset, width);
|
||||
}
|
||||
|
||||
}.bind(this), (err) => {
|
||||
|
@ -331,7 +333,7 @@ class DefaultViewManager {
|
|||
this.emit(EVENTS.MANAGERS.RESIZE, view.section);
|
||||
}
|
||||
|
||||
moveTo(offset){
|
||||
moveTo(offset, width){
|
||||
var distX = 0,
|
||||
distY = 0;
|
||||
|
||||
|
@ -344,6 +346,15 @@ class DefaultViewManager {
|
|||
distX = this.container.scrollWidth - this.layout.delta;
|
||||
}
|
||||
}
|
||||
if(this.settings.direction === 'rtl'){
|
||||
/***
|
||||
the `floor` function above (L343) is on positive values, so we should add one `layout.delta`
|
||||
to distX or use `Math.ceil` function, or multiply offset.left by -1
|
||||
before `Math.floor`
|
||||
*/
|
||||
distX = distX + this.layout.delta
|
||||
distX = distX - width
|
||||
}
|
||||
this.scrollTo(distX, distY, true);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue