From 4608b68093821d26f416a57f518dc8cd58ad01ca Mon Sep 17 00:00:00 2001
From: mat <github@matdoes.dev>
Date: Fri, 4 Mar 2022 23:08:29 -0600
Subject: fix svelte error

---
 src/lib/BackgroundImage.svelte | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

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

diff --git a/src/lib/BackgroundImage.svelte b/src/lib/BackgroundImage.svelte
index c059119..19144e2 100644
--- a/src/lib/BackgroundImage.svelte
+++ b/src/lib/BackgroundImage.svelte
@@ -15,8 +15,11 @@
 		bodyStyle = ''
 		// hack since sometimes the style is not removed
 		if (browser) {
-			let styleEl = document.getElementById('background-image-style')
-			if (styleEl) styleEl.remove()
+			// if we don't wait a frame, svelte gives an error sometimes
+			requestAnimationFrame(() => {
+				let styleEl = document.getElementById('background-image-style')
+				if (styleEl) styleEl.remove()
+			})
 		}
 	})
 </script>
-- 
cgit 

