feat: add landing

This commit is contained in:
Kentai Radiquum 2024-09-14 13:54:03 +05:00
parent f94a1bb008
commit b09a84afbe
Signed by: Radiquum
GPG key ID: 858E8EE696525EED
3 changed files with 115 additions and 65 deletions

View file

@ -17,7 +17,46 @@ function updatePlayingTrack() {
});
}
function getScrollPosition () {
const height =
document.documentElement.scrollHeight -
document.documentElement.clientHeight;
const windowScroll = document.documentElement.scrollTop;
const scrolled = (windowScroll / height) * 100;
return Math.floor(scrolled)
}
window.onload = () => {
updatePlayingTrack();
setInterval(updatePlayingTrack, 360000);
}
const header = document.getElementById("header")
let last_Y_pos = 0
let header_opacity = 0
window.onscroll = () => {
let scrollPosition = getScrollPosition()
console.log(last_Y_pos, window.scrollY, scrollPosition, header_opacity)
if (scrollPosition < 20) {
header.style.display = "none"
} else {
header.style.display = "block"
}
if ((window.scrollY > last_Y_pos) && (scrollPosition > 40)) {
header_opacity += 0.1
} else if ((window.scrollY < last_Y_pos) && (scrollPosition < 40)) (
header_opacity -= 0.1
)
last_Y_pos = window.scrollY
if (header_opacity > 1) {
header_opacity = 1
} else if (header_opacity < 0) {
header_opacity = 0
}
header.style.setProperty("--header-opacity", `${header_opacity.toFixed(2)}`)
}