websitedesign2023/docs/assets/js/scroll.js

25 lines
731 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]
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"
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
}
} else {
header.style.padding = "10px"
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-01-18 12:45:47 -06:00
}