From 703cf2b4ef2be38e0e86bd32fa31eb28b45165aa Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Sun, 14 Apr 2024 23:08:20 -0700
Subject: feat(popup): disable scroll while active

---
 src/lib/Popup.svelte | 8 ++++++++
 1 file changed, 8 insertions(+)

(limited to 'src/lib/Popup.svelte')

diff --git a/src/lib/Popup.svelte b/src/lib/Popup.svelte
index badd4f2c..7c9949af 100644
--- a/src/lib/Popup.svelte
+++ b/src/lib/Popup.svelte
@@ -1,4 +1,6 @@
 <script lang="ts">
+	import { browser } from '$app/environment';
+
 	export let onLeave = () => {
 		return;
 	};
@@ -16,6 +18,12 @@
 			onLeave();
 		}
 	};
+
+	$: {
+		if (browser)
+			if (show) document.body.style.overflow = 'hidden';
+			else document.body.style.overflow = 'auto';
+	}
 </script>
 
 <svelte:window on:click={handleClickOutside} />
-- 
cgit v1.2.3

