mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-03 14:59:18 +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) {
|
if(target) {
|
||||||
let offset = visible.locationOf(target);
|
let offset = visible.locationOf(target);
|
||||||
this.moveTo(offset);
|
let width = visible.width();
|
||||||
|
this.moveTo(offset, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
displaying.resolve();
|
displaying.resolve();
|
||||||
|
@ -298,7 +299,8 @@ class DefaultViewManager {
|
||||||
// Move to correct place within the section, if needed
|
// Move to correct place within the section, if needed
|
||||||
if(target) {
|
if(target) {
|
||||||
let offset = view.locationOf(target);
|
let offset = view.locationOf(target);
|
||||||
this.moveTo(offset);
|
let width = view.width();
|
||||||
|
this.moveTo(offset, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
}.bind(this), (err) => {
|
}.bind(this), (err) => {
|
||||||
|
@ -331,7 +333,7 @@ class DefaultViewManager {
|
||||||
this.emit(EVENTS.MANAGERS.RESIZE, view.section);
|
this.emit(EVENTS.MANAGERS.RESIZE, view.section);
|
||||||
}
|
}
|
||||||
|
|
||||||
moveTo(offset){
|
moveTo(offset, width){
|
||||||
var distX = 0,
|
var distX = 0,
|
||||||
distY = 0;
|
distY = 0;
|
||||||
|
|
||||||
|
@ -344,6 +346,15 @@ class DefaultViewManager {
|
||||||
distX = this.container.scrollWidth - this.layout.delta;
|
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);
|
this.scrollTo(distX, distY, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue