websitedesign2023/docs/assets/js/scroll.js

32 lines
969 B
JavaScript
Raw Normal View History

2023-01-18 12:45:47 -06:00
window.onscroll = () => {
2023-01-18 15:44:59 -06:00
headerScroll()
2023-01-18 12:45:47 -06:00
}
2023-01-18 15:44:59 -06:00
const header = document.getElementsByTagName("header")[0]
2023-04-18 12:44:33 -05:00
const logo = document.getElementsByClassName("logo")[0]
2023-01-18 15:44:59 -06:00
const headerText = document.getElementsByTagName("h1")[0]
const headerButtons = document.getElementsByTagName("ul")[0].children
2023-01-18 12:45:47 -06:00
function headerScroll() {
2023-01-18 15:44:59 -06:00
if (document.body.scrollTop > 50 || document.documentElement.scrollTop > 50) {
header.style.padding = "5px"
2023-04-18 12:44:33 -05:00
logo.style.width = "50px"
logo.style.height = "50px"
2023-01-18 15:44:59 -06:00
headerText.style.fontSize = "16px"
headerText.style.padding = "5px"
for (const button of headerButtons) {
button.children[0].className = "navscroll"
2023-01-18 15:44:59 -06:00
}
2023-02-08 13:29:21 -06:00
menuButton.style.width = "20px"
2023-01-18 15:44:59 -06:00
} else {
header.style.padding = "10px"
2023-04-18 12:44:33 -05:00
logo.style.width = "75px"
logo.style.height = "75px"
2023-01-18 15:44:59 -06:00
headerText.style.fontSize = "32px"
headerText.style.padding = "10px"
for (const button of headerButtons) {
button.children[0].className = ""
2023-01-18 15:44:59 -06:00
}
2023-02-08 13:29:21 -06:00
menuButton.style.width = "25px"
2023-01-18 15:44:59 -06:00
}
2023-01-18 12:45:47 -06:00
}