Skip to content

Commit 5bb2ee7

Browse files
committed
2 parents e607014 + 526c028 commit 5bb2ee7

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/Viewport.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ export interface IViewportTransformState
112112
}
113113

114114
const 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

src/plugins/Drag.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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);

src/plugins/Wheel.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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))

0 commit comments

Comments
 (0)