Skip to content

Commit

Permalink
Fix window state
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaitanLyss committed Sep 4, 2024
1 parent d90321d commit 2e214f0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/lib/utils/html.svelte.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
3 changes: 1 addition & 2 deletions src/lib/utils/html.test.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down
14 changes: 14 additions & 0 deletions src/routes/html/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script lang="ts">
import { WindowState } from "$lib";
const windowState = new WindowState();
</script>

<div class="grid-cols-2">
<span>Width</span>
<span>{windowState.width}</span>
<span>Height</span>
<span>{windowState.height}</span>


</div>

0 comments on commit 2e214f0

Please sign in to comment.