1
0
Fork 0
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:
Fred Chasen 2017-11-01 12:20:28 -07:00
parent 5f53b7223c
commit e2b9ab6f3a

View file

@ -31,6 +31,8 @@ class Contents {
this.sectionIndex = sectionIndex || 0;
this.cfiBase = cfiBase || "";
this.epubReadingSystem("epub.js", ePub.VERSION);
this.listeners();
}
@ -755,6 +757,8 @@ class Contents {
size(width, height){
var viewport = { scale: 1.0, scalable: "no" };
this.layoutStyle("scrolling");
if (width >= 0) {
this.width(width);
viewport.width = width;
@ -779,6 +783,8 @@ class Contents {
var COLUMN_WIDTH = prefixed("column-width");
var COLUMN_FILL = prefixed("column-fill");
this.layoutStyle("paginated");
// Fix body width issues if rtl is only set on body element
if (this.content.dir === "rtl") {
this.direction("rtl");
@ -827,6 +833,8 @@ class Contents {
var offsetY = (height - (viewport.height * scale)) / 2;
this.layoutStyle("paginated");
this.width(width);
this.height(height);
this.overflow("hidden");
@ -865,6 +873,43 @@ class Contents {
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() {
// Stop observing
if(this.observer) {