Skip to content

Commit 82dede0

Browse files
Merge pull request #12354 from Snuffleupagus/BaseViewer-container-position-absolute
Ensure that the `container` div, on `BaseViewer`-instances, is absolutely positioned
2 parents e51e9d1 + c27dcf2 commit 82dede0

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

web/base_viewer.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,21 @@ class BaseViewer {
145145
this.viewer = options.viewer || options.container.firstElementChild;
146146

147147
if (
148-
(typeof PDFJSDev === "undefined" ||
149-
PDFJSDev.test("!PRODUCTION || GENERIC")) &&
150-
!(
151-
this.container instanceof HTMLDivElement &&
152-
this.viewer instanceof HTMLDivElement
153-
)
148+
typeof PDFJSDev === "undefined" ||
149+
PDFJSDev.test("!PRODUCTION || GENERIC")
154150
) {
155-
throw new Error("Invalid `container` and/or `viewer` option.");
151+
if (
152+
!(
153+
this.container instanceof HTMLDivElement &&
154+
this.viewer instanceof HTMLDivElement
155+
)
156+
) {
157+
throw new Error("Invalid `container` and/or `viewer` option.");
158+
}
159+
160+
if (getComputedStyle(this.container).position !== "absolute") {
161+
throw new Error("The `container` must be absolutely positioned.");
162+
}
156163
}
157164
this.eventBus = options.eventBus;
158165
this.linkService = options.linkService || new SimpleLinkService();

0 commit comments

Comments
 (0)