mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-04 15:09:16 +02:00
Updated RTL to apply to HTML element and position right for Firefox
This commit is contained in:
parent
aaa5703565
commit
da11659d6c
10 changed files with 157 additions and 29 deletions
File diff suppressed because one or more lines are too long
44
reader/js/epub.min.js
vendored
44
reader/js/epub.min.js
vendored
|
@ -5787,8 +5787,13 @@ EPUBJS.Render.Iframe.prototype.load = function(chapter){
|
|||
render.bodyEl.style.margin = "0";
|
||||
}
|
||||
|
||||
if(render.direction && render.bodyEl.dir != "rtl"){
|
||||
render.bodyEl.dir = "rtl";
|
||||
// HTML element must have direction set if RTL or columnns will
|
||||
// not be in the correct direction in Firefox
|
||||
// Firefox also need the html element to be position right
|
||||
if(render.direction == "rtl" && render.docEl.dir != "rtl"){
|
||||
render.docEl.dir = "rtl";
|
||||
render.docEl.style.position = "absolute";
|
||||
render.docEl.style.right = "0";
|
||||
}
|
||||
|
||||
deferred.resolve(render.docEl);
|
||||
|
@ -5859,7 +5864,16 @@ EPUBJS.Render.Iframe.prototype.setPageDimensions = function(pageWidth, pageHeigh
|
|||
};
|
||||
|
||||
EPUBJS.Render.Iframe.prototype.setDirection = function(direction){
|
||||
|
||||
this.direction = direction;
|
||||
|
||||
// Undo previous changes if needed
|
||||
if(this.docEl && this.docEl.dir == "rtl"){
|
||||
this.docEl.dir = "rtl";
|
||||
this.docEl.style.position = "static";
|
||||
this.docEl.style.right = "auto";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
EPUBJS.Render.Iframe.prototype.setLeft = function(leftPos){
|
||||
|
@ -5933,6 +5947,11 @@ EPUBJS.Render.Iframe.prototype.getBaseElement = function(){
|
|||
return this.bodyEl;
|
||||
};
|
||||
|
||||
// Return the document element
|
||||
EPUBJS.Render.Iframe.prototype.getDocumentElement = function(){
|
||||
return this.docEl;
|
||||
};
|
||||
|
||||
// Checks if an element is on the screen
|
||||
EPUBJS.Render.Iframe.prototype.isElementVisible = function(el){
|
||||
var rect;
|
||||
|
@ -6630,11 +6649,24 @@ EPUBJS.Renderer.prototype.mapPage = function(){
|
|||
|
||||
|
||||
};
|
||||
var dir = root.dir;
|
||||
|
||||
root.dir = "ltr";
|
||||
var docEl = this.render.getDocumentElement();
|
||||
var dir = docEl.dir;
|
||||
|
||||
// Set back to ltr before sprinting to get correct order
|
||||
if(dir == "rtl") {
|
||||
docEl.dir = "ltr";
|
||||
docEl.style.position = "static";
|
||||
}
|
||||
|
||||
this.sprint(root, check);
|
||||
root.dir = dir;
|
||||
|
||||
// Reset back to previous RTL settings
|
||||
if(dir == "rtl") {
|
||||
docEl.dir = dir;
|
||||
docEl.style.left = "auto";
|
||||
docEl.style.right = "0";
|
||||
}
|
||||
|
||||
// this.textSprint(root, checkText);
|
||||
|
||||
if(prevRange){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue