Rename scroll position variable
This commit is contained in:
parent
3f727a9e8e
commit
4180752d42
|
@ -65,9 +65,9 @@
|
||||||
// const hero = document.querySelector(".hero");
|
// const hero = document.querySelector(".hero");
|
||||||
const navbar = document.querySelector(".navbar");
|
const navbar = document.querySelector(".navbar");
|
||||||
window.addEventListener("scroll", () => {
|
window.addEventListener("scroll", () => {
|
||||||
const scrollPos = window.scrollY || document.documentElement.scrollTop;
|
const scrollPosition = window.scrollY || document.documentElement.scrollTop;
|
||||||
const stickyLine = hero.scrollHeight - navbar.scrollHeight;
|
const stickyLine = hero.scrollHeight - navbar.scrollHeight;
|
||||||
if (scrollPos > stickyLine) {
|
if (scrollPosition > stickyLine) {
|
||||||
navbar.classList.add("nav--sticky");
|
navbar.classList.add("nav--sticky");
|
||||||
} else {
|
} else {
|
||||||
navbar.classList.remove("nav--sticky");
|
navbar.classList.remove("nav--sticky");
|
||||||
|
|
Loading…
Reference in New Issue