From 2e214f0cfe15f3e82159e1fc084d38332f3a5c88 Mon Sep 17 00:00:00 2001 From: MoonLyss Date: Wed, 4 Sep 2024 19:33:39 +0200 Subject: [PATCH] Fix window state --- src/lib/utils/html.svelte.ts | 2 +- src/lib/utils/html.test.ts | 3 +-- src/routes/html/+page.svelte | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 src/routes/html/+page.svelte diff --git a/src/lib/utils/html.svelte.ts b/src/lib/utils/html.svelte.ts index ddf4574..2aca714 100644 --- a/src/lib/utils/html.svelte.ts +++ b/src/lib/utils/html.svelte.ts @@ -1,6 +1,6 @@ import type { Position } from './math'; -const _windowState = $state({ width: NaN, height: NaN }); +const _windowState = $state({ width: 1879, height: 961 }); let _isWindowStateSetup = false; /** * Reactive window state for use in svelte 5. diff --git a/src/lib/utils/html.test.ts b/src/lib/utils/html.test.ts index 115ed37..4e8fe5a 100644 --- a/src/lib/utils/html.test.ts +++ b/src/lib/utils/html.test.ts @@ -1,6 +1,5 @@ import { describe, expect, it } from 'vitest'; -import { Rect, WindowState, download, isBrowser } from './html.svelte'; -import { Window } from 'happy-dom'; +import { Rect, WindowState, isBrowser } from './html.svelte'; describe('WindowState', () => { it('should return the window width', () => { diff --git a/src/routes/html/+page.svelte b/src/routes/html/+page.svelte new file mode 100644 index 0000000..314cb08 --- /dev/null +++ b/src/routes/html/+page.svelte @@ -0,0 +1,14 @@ + + +
+ Width + {windowState.width} + Height + {windowState.height} + + +
\ No newline at end of file