mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-05 15:32:55 +02:00
Add Destroy to view managers
This commit is contained in:
parent
db727b00a9
commit
d95ec97f7f
10 changed files with 118 additions and 59 deletions
|
@ -85,9 +85,11 @@ class DefaultViewManager {
|
|||
}
|
||||
|
||||
destroy(){
|
||||
// this.views.each(function(view){
|
||||
// view.destroy();
|
||||
// });
|
||||
this.views.each(function(view){
|
||||
view.destroy();
|
||||
});
|
||||
|
||||
this.stage.destroy();
|
||||
|
||||
/*
|
||||
|
||||
|
@ -108,7 +110,6 @@ class DefaultViewManager {
|
|||
}
|
||||
|
||||
resize(width, height){
|
||||
|
||||
// Clear the queue
|
||||
this.q.clear();
|
||||
|
||||
|
@ -119,12 +120,13 @@ class DefaultViewManager {
|
|||
this.viewSettings.width = this._stageSize.width;
|
||||
this.viewSettings.height = this._stageSize.height;
|
||||
|
||||
this.updateLayout();
|
||||
|
||||
// Update for existing views
|
||||
this.views.each(function(view) {
|
||||
view.size(this._stageSize.width, this._stageSize.height);
|
||||
}.bind(this));
|
||||
|
||||
this.updateLayout();
|
||||
|
||||
this.emit("resized", {
|
||||
width: this.stage.width,
|
||||
|
|
|
@ -225,6 +225,23 @@ class Stage {
|
|||
|
||||
this.sheet.insertRule(scope + selector + " {" + rules + "}", 0);
|
||||
}
|
||||
|
||||
destroy() {
|
||||
var base;
|
||||
|
||||
if (this.element) {
|
||||
|
||||
if(this.settings.hidden) {
|
||||
base = this.wrapper;
|
||||
} else {
|
||||
base = this.container;
|
||||
}
|
||||
|
||||
if(this.element.contains(this.container)) {
|
||||
this.element.removeChild(this.container);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Stage;
|
||||
|
|
|
@ -237,17 +237,19 @@ class IframeView {
|
|||
if(this.layout.name === "pre-paginated") return;
|
||||
|
||||
this._expanding = true;
|
||||
|
||||
// Expand Horizontally
|
||||
// if(height && !width) {
|
||||
if(this.settings.axis === "horizontal") {
|
||||
// Get the width of the text
|
||||
textWidth = this.contents.textWidth();
|
||||
width = this.contentWidth(textWidth);
|
||||
|
||||
// Check if the textWidth has changed
|
||||
if(textWidth != this._textWidth){
|
||||
if(width != this._width){
|
||||
// Get the contentWidth by resizing the iframe
|
||||
// Check with a min reset of the textWidth
|
||||
width = this.contentWidth(textWidth);
|
||||
|
||||
// width = this.contentWidth(textWidth);
|
||||
|
||||
columns = Math.ceil(width / (this.settings.layout.columnWidth + this.settings.layout.gap));
|
||||
|
||||
|
@ -260,6 +262,7 @@ class IframeView {
|
|||
|
||||
// Save the textWdith
|
||||
this._textWidth = textWidth;
|
||||
|
||||
// Save the contentWidth
|
||||
this._contentWidth = width;
|
||||
} else {
|
||||
|
@ -344,6 +347,7 @@ class IframeView {
|
|||
// this._needsReframe = true;
|
||||
// return;
|
||||
// }
|
||||
|
||||
if(isNumber(width)){
|
||||
this.element.style.width = width + "px";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue