mirror of
https://github.com/Radiquum/radiquum.github.io.git
synced 2025-05-07 21:39:34 +05:00
feat: add landing
This commit is contained in:
parent
f94a1bb008
commit
b09a84afbe
3 changed files with 115 additions and 65 deletions
|
@ -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)}`)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue