diff --git a/src/managers/helpers/views.js b/src/managers/helpers/views.js index 4368da2..5233633 100644 --- a/src/managers/helpers/views.js +++ b/src/managers/helpers/views.js @@ -77,9 +77,7 @@ class Views { } destroy(view) { - if(view.displayed){ - view.destroy(); - } + view.destroy(); if(this.container){ this.container.removeChild(view.element); diff --git a/src/managers/views/iframe.js b/src/managers/views/iframe.js index e20e54d..0b16e96 100644 --- a/src/managers/views/iframe.js +++ b/src/managers/views/iframe.js @@ -6,7 +6,12 @@ import { EVENTS } from "../../utils/constants"; import { Pane, Highlight, Underline } from "marks-pane"; class IframeView { + static ViewMap = new Map(); constructor(section, options) { + const oldView = IframeView.ViewMap.get(section.href); + if (oldView) oldView.destroy(); + IframeView.ViewMap.set(section.href, this); + this.settings = extend({ ignoreClass : "", axis: undefined, //options.layout && options.layout.props.flow === "scrolled" ? "vertical" : "horizontal", @@ -48,6 +53,7 @@ class IframeView { this.highlights = {}; this.underlines = {}; this.marks = {}; + this.loading = undefined; } @@ -98,7 +104,7 @@ class IframeView { if (this.settings.allowPopups) { this.iframe.sandbox += " allow-popups"; } - + this.iframe.setAttribute("enable-annotation", "true"); this.resizing = true; @@ -158,7 +164,6 @@ class IframeView { return this.load(contents); }.bind(this)) .then(function(){ - // find and report the writingMode axis let writingMode = this.contents.writingMode(); @@ -382,7 +387,8 @@ class IframeView { load(contents) { - var loading = new defer(); + this.loading && this.loading.reject('cancel'); + var loading = this.loading = new defer(); var loaded = loading.promise; if(!this.iframe) { @@ -841,6 +847,9 @@ class IframeView { this._height = null; } + this.loading && this.loading.reject('cancel'); + + // this.element.style.height = "0px"; // this.element.style.width = "0px"; }