mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-02 14:49:16 +02:00
Updates for rendering in embedded Webviews (#643)
* Initial embedding support * Updates for rendering in embedded webviews * toLowerCase nodeName check
This commit is contained in:
parent
5cc8b191d0
commit
bb1ab21a33
23 changed files with 987 additions and 213 deletions
|
@ -182,6 +182,9 @@ class Rendition {
|
|||
// Listen for resizing
|
||||
this.manager.on("resized", this.onResized.bind(this));
|
||||
|
||||
// Listen for rotation
|
||||
this.manager.on("orientationChange", this.onOrientationChange.bind(this));
|
||||
|
||||
// Listen for scroll changes
|
||||
this.manager.on("scrolled", this.reportLocation.bind(this));
|
||||
|
||||
|
@ -342,7 +345,8 @@ class Rendition {
|
|||
*/
|
||||
onResized(size){
|
||||
|
||||
if(this.location) {
|
||||
if (this.location) {
|
||||
// this.manager.clear();
|
||||
this.display(this.location.start.cfi);
|
||||
}
|
||||
|
||||
|
@ -353,6 +357,19 @@ class Rendition {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Report orientation events and display the last seen location
|
||||
* @private
|
||||
*/
|
||||
onOrientationChange(orientation){
|
||||
if (this.location) {
|
||||
this.manager.clear();
|
||||
this.display(this.location.start.cfi);
|
||||
}
|
||||
|
||||
this.emit("orientationChange", orientation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the Rendition to a specific offset
|
||||
* Usually you would be better off calling display()
|
||||
|
@ -443,9 +460,18 @@ class Rendition {
|
|||
this._layout.flow(_flow);
|
||||
}
|
||||
|
||||
if (this.manager && this._layout) {
|
||||
this.manager.applyLayout(this._layout);
|
||||
}
|
||||
|
||||
if (this.manager) {
|
||||
this.manager.updateFlow(_flow);
|
||||
}
|
||||
|
||||
if (this.location) {
|
||||
this.manager.clear();
|
||||
this.display(this.location.start.cfi);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -538,8 +564,11 @@ class Rendition {
|
|||
}
|
||||
|
||||
located(location){
|
||||
if (!location.length) {
|
||||
return {};
|
||||
}
|
||||
let start = location[0];
|
||||
let end = location[location.length-1]
|
||||
let end = location[location.length-1];
|
||||
|
||||
let located = {
|
||||
start: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue