Last active
April 30, 2022 11:27
-
-
Save Ennoriel/8c89dc3615292f0a40b04f4f876afd77 to your computer and use it in GitHub Desktop.
Observer Component to update a --vh css variable in order to have the right height on desktop & mobile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import { onMount } from 'svelte'; | |
onMount(resize); | |
function resize() { | |
let vh = window.innerHeight * 0.01; | |
document.documentElement.style.setProperty('--vh', `${vh}px`); | |
} | |
</script> | |
<svelte:window on:resize /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment