Skip to content

Commit

Permalink
Check scroll position on page load
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellrgn committed Oct 23, 2024
1 parent 134c12f commit 504cc6e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,20 @@
onMount(() => {
window.onscroll = function() {scrollFunction()};
scrollFunction();
});
function scrollFunction() {
closeNav();
if (window.scrollY > 40) {
document.getElementById("nav-image").classList.add("scrolling");
document.getElementById("nav-image")?.classList.add("scrolling");
document.getElementsByClassName("navbar")[0].classList.add("scrolling");
let es = document.getElementsByClassName("nav-text");
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.getElementById("nav-image")?.classList.remove("scrolling");
document.getElementsByClassName("navbar")[0].classList.remove("scrolling");
let es = document.getElementsByClassName("nav-text");
for(let i = 0; i < es.length; i++) {
Expand Down

0 comments on commit 504cc6e

Please sign in to comment.