1
1
import throwIfMissing from "./util/throwIfMissing" ;
2
2
import { addClasses , removeClasses } from "./util/dom" ;
3
3
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
-
11
4
export default class ZoomPane {
12
5
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
+
13
14
this . _completeShow = this . _completeShow . bind ( this ) ;
14
15
this . _completeHide = this . _completeHide . bind ( this ) ;
15
16
this . _handleLoad = this . _handleLoad . bind ( this ) ;
@@ -197,7 +198,7 @@ export default class ZoomPane {
197
198
this . _showInContainer ( ) ;
198
199
}
199
200
200
- if ( HAS_ANIMATION ) {
201
+ if ( this . HAS_ANIMATION ) {
201
202
this . el . addEventListener ( "animationend" , this . _completeShow , false ) ;
202
203
this . el . addEventListener ( "webkitAnimationEnd" , this . _completeShow , false ) ;
203
204
addClasses ( this . el , this . openingClasses ) ;
@@ -217,7 +218,7 @@ export default class ZoomPane {
217
218
this . _removeListenersAndResetClasses ( ) ;
218
219
this . isShowing = false ;
219
220
220
- if ( HAS_ANIMATION ) {
221
+ if ( this . HAS_ANIMATION ) {
221
222
this . el . addEventListener ( "animationend" , this . _completeHide , false ) ;
222
223
this . el . addEventListener ( "webkitAnimationEnd" , this . _completeHide , false ) ;
223
224
addClasses ( this . el , this . closingClasses ) ;
0 commit comments