From 727ad62591226c7554d4ee398cfd8b62fb404451 Mon Sep 17 00:00:00 2001 From: Daniel Lorigan Date: Mon, 2 Dec 2024 22:22:12 -0800 Subject: [PATCH] Add checks to scrollbar to handle auth preload state --- src/routes/(app)/+layout.svelte | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte index 597f87b7..ea21e548 100644 --- a/src/routes/(app)/+layout.svelte +++ b/src/routes/(app)/+layout.svelte @@ -53,15 +53,17 @@ function scrollFunction() { if (window.scrollY > 40) { document.getElementById("nav-image")?.classList.add("scrolling"); - document.getElementsByClassName("navbar")[0].classList.add("scrolling"); + document.getElementsByClassName("navbar")?.[0].classList.add("scrolling"); let es = document.getElementsByClassName("nav-text"); + if (es.length == 0) return; for(let i = 0; i < es.length; i++) { es[i].classList.add("scrolling"); } } else if (window.scrollY == 0) { document.getElementById("nav-image")?.classList.remove("scrolling"); - document.getElementsByClassName("navbar")[0].classList.remove("scrolling"); + document.getElementsByClassName("navbar")?.[0].classList.remove("scrolling"); let es = document.getElementsByClassName("nav-text"); + if (es.length == 0) return; for(let i = 0; i < es.length; i++) { es[i].classList.remove("scrolling"); }