Skip to content

Commit

Permalink
KAW-7904 Fix init state of the header
Browse files Browse the repository at this point in the history
  • Loading branch information
TomaszDziezykNetcentric committed Sep 12, 2024
1 parent 6a680fa commit c0d50bd
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions blocks/header/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ function handleTransparentAndScrolling(nav) {
const header = nav.closest('header');
let prevScrollingPosition = 0;

document.addEventListener('scroll', () => {
const { scrollY } = window;

const changeToTransparentIfNeeded = (scrollY) => {
if (useTransparentVariant) {
header.classList.add('transparent', 'can-be-transparent');

Expand All @@ -136,6 +134,12 @@ function handleTransparentAndScrolling(nav) {
header.classList.add('transparent');
}
}
};

document.addEventListener('scroll', () => {
const { scrollY } = window;

changeToTransparentIfNeeded(scrollY);

if (scrollY - prevScrollingPosition > 0 && scrollY > 200) {
header.classList.add('fade-out');
Expand All @@ -145,6 +149,8 @@ function handleTransparentAndScrolling(nav) {

prevScrollingPosition = scrollY;
});

changeToTransparentIfNeeded(window.scrollY);
}

/**
Expand Down

0 comments on commit c0d50bd

Please sign in to comment.