Skip to content

Commit

Permalink
feat: use innerHeight and innerWidth from svelte/reactivity (fixes: #339
Browse files Browse the repository at this point in the history
  • Loading branch information
ryoppippi committed Dec 29, 2024
1 parent 41969fd commit 0647931
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/lib/Backgroud/Backgroud.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang='ts'>
import { prefersReducedMotion } from 'svelte/motion';
import { innerHeight, innerWidth } from 'svelte/reactivity/window';
import { animate, cancelAnimate, createCircles } from './circle.js';
/**
Expand All @@ -19,8 +20,6 @@
let canvas = $state<HTMLCanvasElement | undefined>(undefined);
const ctx = $derived.by(() => canvas?.getContext('2d'));
let width = $state(0);
let height = $state(0);
/** jsが読み込まれたかどうか */
let jsLoaded = $state(false);
Expand Down Expand Up @@ -50,7 +49,6 @@
});
</script>

<svelte:window bind:innerWidth={width} bind:innerHeight={height} />
<!-- svelte-ignore element_invalid_self_closing_tag -->
<div
uno-bg-LP-backgroud
Expand All @@ -67,7 +65,7 @@
<canvas
bind:this={canvas}
style:--blur='{blurStrength}px'
height={height + blurStrength * 4}
height={innerHeight.current ?? 0 + blurStrength * 4}
uno-bg-LP-backgroud
uno-filter-blur='[--blur]'
uno-left='50%'
Expand All @@ -77,7 +75,7 @@
uno-transform-translate-x='-50%'
uno-transform-translate-y='-50%'
uno-z-1
width={width + blurStrength * 4}
width={innerWidth.current ?? 0 + blurStrength * 4}
/>
{/if}
</div>

0 comments on commit 0647931

Please sign in to comment.