Skip to content

Instantly share code, notes, and snippets.

@Ennoriel
Last active April 30, 2022 11:27
Show Gist options
  • Save Ennoriel/8c89dc3615292f0a40b04f4f876afd77 to your computer and use it in GitHub Desktop.
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
<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