Add sticky header feature
This commit is contained in:
20
sticky-header/steacky-header.js
Normal file
20
sticky-header/steacky-header.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const HEADER_POINT = 70;
|
||||
let lastScrollY = window.scrollY;
|
||||
|
||||
window.addEventListener("scroll", () => {
|
||||
if (app_shop.vars.view === 1 || app_shop.vars.view === 2) return;
|
||||
|
||||
const container = document.querySelector("#container");
|
||||
if (container.classList.contains("projector_page")) return;
|
||||
|
||||
const bodyEl = document.querySelector("body");
|
||||
const currentScroll = window.scrollY;
|
||||
|
||||
if (currentScroll < lastScrollY && currentScroll > HEADER_POINT) {
|
||||
bodyEl.classList.add("desktop-menu__scroll");
|
||||
} else {
|
||||
bodyEl.classList.remove("desktop-menu__scroll");
|
||||
}
|
||||
|
||||
lastScrollY = currentScroll;
|
||||
});
|
||||
Reference in New Issue
Block a user