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

Master #101

Merged
merged 3 commits into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion navigator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@readium/navigator",
"version": "1.3.3",
"version": "1.3.4",
"type": "module",
"description": "Next generation SDK for publications in Web Apps",
"author": "readium",
15 changes: 9 additions & 6 deletions navigator/src/epub/frame/FrameManager.ts
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ export class FrameManager {
private loader: Loader | undefined;
public readonly source: string;
private comms: FrameComms | undefined;
private destroyed: boolean = false;

private currModules: ModuleName[] = [];

@@ -57,15 +58,17 @@ export class FrameManager {
await this.hide();
this.loader?.destroy();
this.frame.remove();
this.destroyed = true;
}

async hide(): Promise<void> {
if(this.destroyed) return;
this.frame.style.visibility = "hidden";
this.frame.style.setProperty("aria-hidden", "true");
this.frame.style.opacity = "0";
this.frame.style.pointerEvents = "none";
if(this.frame.parentElement) {
if(this.comms === undefined) return;
if(this.comms === undefined || !this.comms.ready) return;
return new Promise((res, _) => {
this.comms?.send("unfocus", undefined, (_: boolean) => {
this.comms?.halt();
@@ -77,10 +80,8 @@ export class FrameManager {
}

async show(atProgress?: number): Promise<void> {
if(!this.frame.parentElement) {
console.warn("Trying to show frame that is not attached to the DOM");
return;
}
if(this.destroyed) throw Error("Trying to show frame when it doesn't exist");
if(!this.frame.parentElement) throw Error("Trying to show frame that is not attached to the DOM");
if(this.comms) this.comms.resume();
else this.comms = new FrameComms(this.frame.contentWindow!, this.source);
return new Promise((res, _) => {
@@ -104,15 +105,17 @@ export class FrameManager {
}

get iframe() {
if(this.destroyed) throw Error("Trying to use frame when it doesn't exist");
return this.frame;
}

get realSize() {
if(this.destroyed) throw Error("Trying to use frame client rect when it doesn't exist");
return this.frame.getBoundingClientRect();
}

get window() {
if(!this.frame.contentWindow) throw Error("Trying to use frame window when it doesn't exist");
if(this.destroyed || !this.frame.contentWindow) throw Error("Trying to use frame window when it doesn't exist");
return this.frame.contentWindow;
}