Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(iframe-view): can't turn pages after changing window size #1336

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/managers/helpers/views.js
Expand Up @@ -77,9 +77,7 @@ class Views {
}

destroy(view) {
if(view.displayed){
view.destroy();
}
view.destroy();

if(this.container){
this.container.removeChild(view.element);
Expand Down
15 changes: 12 additions & 3 deletions src/managers/views/iframe.js
Expand Up @@ -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);
Comment on lines +9 to +13
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the previous instance of the current page is destroyed to prevent promise blocking.


this.settings = extend({
ignoreClass : "",
axis: undefined, //options.layout && options.layout.props.flow === "scrolled" ? "vertical" : "horizontal",
Expand Down Expand Up @@ -48,6 +53,7 @@ class IframeView {
this.highlights = {};
this.underlines = {};
this.marks = {};
this.loading = undefined;

}

Expand Down Expand Up @@ -98,7 +104,7 @@ class IframeView {
if (this.settings.allowPopups) {
this.iframe.sandbox += " allow-popups";
}

this.iframe.setAttribute("enable-annotation", "true");

this.resizing = true;
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -382,7 +387,8 @@ class IframeView {


load(contents) {
var loading = new defer();
this.loading && this.loading.reject('cancel');
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure the last promise is released.

var loading = this.loading = new defer();
var loaded = loading.promise;

if(!this.iframe) {
Expand Down Expand Up @@ -841,6 +847,9 @@ class IframeView {
this._height = null;
}

this.loading && this.loading.reject('cancel');
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure the promise doesn't get stuck in pending, this avoids queue blocking.



// this.element.style.height = "0px";
// this.element.style.width = "0px";
}
Expand Down