We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0574cc7 commit 8e6fe80Copy full SHA for 8e6fe80
apps/svelte.dev/content/tutorial/01-svelte/08-actions/01-actions/+assets/app-a/src/lib/Canvas.svelte
@@ -7,21 +7,17 @@
7
8
$effect(() => {
9
context = canvas.getContext('2d');
10
-
11
- function resize() {
12
- canvas.width = window.innerWidth;
13
- canvas.height = window.innerHeight;
14
- }
15
16
- window.addEventListener('resize', resize);
17
resize();
18
19
- return () => {
20
- window.removeEventListener('resize', resize);
21
- };
22
});
+
+ function resize() {
+ canvas.width = window.innerWidth;
+ canvas.height = window.innerHeight;
+ }
23
</script>
24
+<svelte:window onresize={resize} />
25
<canvas
26
bind:this={canvas}
27
onpointerdown={(e) => {
0 commit comments