mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-04 15:09:16 +02:00
Add epubReadingSystem to Contents
This commit is contained in:
parent
5f53b7223c
commit
e2b9ab6f3a
1 changed files with 45 additions and 0 deletions
|
@ -31,6 +31,8 @@ class Contents {
|
||||||
this.sectionIndex = sectionIndex || 0;
|
this.sectionIndex = sectionIndex || 0;
|
||||||
this.cfiBase = cfiBase || "";
|
this.cfiBase = cfiBase || "";
|
||||||
|
|
||||||
|
this.epubReadingSystem("epub.js", ePub.VERSION);
|
||||||
|
|
||||||
this.listeners();
|
this.listeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -755,6 +757,8 @@ class Contents {
|
||||||
size(width, height){
|
size(width, height){
|
||||||
var viewport = { scale: 1.0, scalable: "no" };
|
var viewport = { scale: 1.0, scalable: "no" };
|
||||||
|
|
||||||
|
this.layoutStyle("scrolling");
|
||||||
|
|
||||||
if (width >= 0) {
|
if (width >= 0) {
|
||||||
this.width(width);
|
this.width(width);
|
||||||
viewport.width = width;
|
viewport.width = width;
|
||||||
|
@ -779,6 +783,8 @@ class Contents {
|
||||||
var COLUMN_WIDTH = prefixed("column-width");
|
var COLUMN_WIDTH = prefixed("column-width");
|
||||||
var COLUMN_FILL = prefixed("column-fill");
|
var COLUMN_FILL = prefixed("column-fill");
|
||||||
|
|
||||||
|
this.layoutStyle("paginated");
|
||||||
|
|
||||||
// Fix body width issues if rtl is only set on body element
|
// Fix body width issues if rtl is only set on body element
|
||||||
if (this.content.dir === "rtl") {
|
if (this.content.dir === "rtl") {
|
||||||
this.direction("rtl");
|
this.direction("rtl");
|
||||||
|
@ -827,6 +833,8 @@ class Contents {
|
||||||
|
|
||||||
var offsetY = (height - (viewport.height * scale)) / 2;
|
var offsetY = (height - (viewport.height * scale)) / 2;
|
||||||
|
|
||||||
|
this.layoutStyle("paginated");
|
||||||
|
|
||||||
this.width(width);
|
this.width(width);
|
||||||
this.height(height);
|
this.height(height);
|
||||||
this.overflow("hidden");
|
this.overflow("hidden");
|
||||||
|
@ -865,6 +873,43 @@ class Contents {
|
||||||
return this.window.getComputedStyle(this.documentElement)[WRITING_MODE] || '';
|
return this.window.getComputedStyle(this.documentElement)[WRITING_MODE] || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
layoutStyle(style) {
|
||||||
|
|
||||||
|
if (style) {
|
||||||
|
this._layoutStyle = style;
|
||||||
|
navigator.epubReadingSystem.layoutStyle = this._layoutStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this._layoutStyle || "paginated";
|
||||||
|
}
|
||||||
|
|
||||||
|
epubReadingSystem(name, version) {
|
||||||
|
navigator.epubReadingSystem = {
|
||||||
|
name: name,
|
||||||
|
version: version,
|
||||||
|
layoutStyle: this.layoutStyle(),
|
||||||
|
hasFeature: function (feature) {
|
||||||
|
switch (feature) {
|
||||||
|
case "dom-manipulation":
|
||||||
|
return true;
|
||||||
|
case "layout-changes":
|
||||||
|
return true;
|
||||||
|
case "touch-events":
|
||||||
|
return true;
|
||||||
|
case "mouse-events":
|
||||||
|
return true;
|
||||||
|
case "keyboard-events":
|
||||||
|
return true;
|
||||||
|
case "spine-scripting":
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return navigator.epubReadingSystem;
|
||||||
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
// Stop observing
|
// Stop observing
|
||||||
if(this.observer) {
|
if(this.observer) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue