File tree Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -112,8 +112,8 @@ export interface IViewportTransformState
112112}
113113
114114const DEFAULT_VIEWPORT_OPTIONS : Partial < ICompleteViewportOptions > = {
115- screenWidth : window . innerWidth ,
116- screenHeight : window . innerHeight ,
115+ screenWidth : typeof window === 'undefined' ? 0 : window . innerWidth ,
116+ screenHeight : typeof window === 'undefined' ? 0 : window . innerHeight ,
117117 worldWidth : null ,
118118 worldHeight : null ,
119119 threshold : 5 ,
@@ -326,8 +326,8 @@ export class Viewport extends Container
326326 * @param {number } [worldHeight]
327327 */
328328 resize (
329- screenWidth : number = window . innerWidth ,
330- screenHeight : number = window . innerHeight ,
329+ screenWidth : number = typeof window === 'undefined' ? 0 : window . innerWidth ,
330+ screenHeight : number = typeof window === 'undefined' ? 0 : window . innerHeight ,
331331 worldWidth ?: number ,
332332 worldHeight ?: number
333333 ) : void
Original file line number Diff line number Diff line change @@ -212,12 +212,14 @@ export class Drag extends Plugin
212212
213213 private addWindowEventHandler ( event : string , handler : ( e : any ) => void ) : void
214214 {
215+ if ( typeof window === 'undefined' ) return ;
215216 window . addEventListener ( event , handler ) ;
216217 this . windowEventHandlers . push ( { event, handler } ) ;
217218 }
218219
219220 public override destroy ( ) : void
220221 {
222+ if ( typeof window === 'undefined' ) return ;
221223 this . windowEventHandlers . forEach ( ( { event, handler } ) =>
222224 {
223225 window . removeEventListener ( event , handler ) ;
Original file line number Diff line number Diff line change @@ -125,6 +125,7 @@ export class Wheel extends Plugin
125125 */
126126 protected handleKeyPresses ( codes : string [ ] ) : void
127127 {
128+ if ( typeof window === 'undefined' ) return ;
128129 window . addEventListener ( 'keydown' , ( e ) =>
129130 {
130131 if ( codes . includes ( e . code ) )
You can’t perform that action at this time.
0 commit comments