Skip to content

Commit 23305b5

Browse files
miljan-aleksicluqven
authored andcommitted
fix: document undefined in no browser environment
1 parent 29664a6 commit 23305b5

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/js/ZoomPane.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import throwIfMissing from "./util/throwIfMissing";
22
import { addClasses, removeClasses } from "./util/dom";
33

4-
// All officially-supported browsers have this, but it's easy to
5-
// account for, just in case.
6-
const divStyle = document.createElement("div").style;
7-
8-
const HAS_ANIMATION =
9-
typeof document === "undefined" ? false : "animation" in divStyle || "webkitAnimation" in divStyle;
10-
114
export default class ZoomPane {
125
constructor(options = {}) {
6+
// All officially-supported browsers have this, but it's easy to
7+
// account for, just in case.
8+
this.HAS_ANIMATION = false;
9+
if (typeof document !== "undefined") {
10+
const divStyle = document.createElement("div").style;
11+
this.HAS_ANIMATION = "animation" in divStyle || "webkitAnimation" in divStyle;
12+
}
13+
1314
this._completeShow = this._completeShow.bind(this);
1415
this._completeHide = this._completeHide.bind(this);
1516
this._handleLoad = this._handleLoad.bind(this);
@@ -197,7 +198,7 @@ export default class ZoomPane {
197198
this._showInContainer();
198199
}
199200

200-
if (HAS_ANIMATION) {
201+
if (this.HAS_ANIMATION) {
201202
this.el.addEventListener("animationend", this._completeShow, false);
202203
this.el.addEventListener("webkitAnimationEnd", this._completeShow, false);
203204
addClasses(this.el, this.openingClasses);
@@ -217,7 +218,7 @@ export default class ZoomPane {
217218
this._removeListenersAndResetClasses();
218219
this.isShowing = false;
219220

220-
if (HAS_ANIMATION) {
221+
if (this.HAS_ANIMATION) {
221222
this.el.addEventListener("animationend", this._completeHide, false);
222223
this.el.addEventListener("webkitAnimationEnd", this._completeHide, false);
223224
addClasses(this.el, this.closingClasses);

0 commit comments

Comments
 (0)