Skip to content

Commit

Permalink
Improve header scrolling smoothness
Browse files Browse the repository at this point in the history
  • Loading branch information
alanrme committed Jul 1, 2024
1 parent 368e9c9 commit a8d9a02
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ span.hu {
opacity: 0.2;

&.active {
transition: 0.15s linear transform;
transition: 0.15s linear;
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,20 @@ ready(() => {
if (header) {
// if the element is at the top of the screen
if (rect.top < 0) {
header.classList.add("sticky")
header.classList.add("sticky")
header.style.transform = `scale(10) translateX(${(rect.top) / (rect.bottom - rect.top)*70}%)`
listenerF = (event) => {
if (event.elapsedTime == 0.5) {
event.target.classList.add("active")
console.log("hi")
} else {
event.target.removeEventListener("transitionend", listenerF)
}
}
header.addEventListener("transitionend", listenerF)
} else {
header.classList.remove("sticky")
header.classList.remove("active")
header.style.transform = null
}
}
Expand Down

0 comments on commit a8d9a02

Please sign in to comment.