Skip to content

Commit

Permalink
change(header): disable sticky setting until feature is more stable
Browse files Browse the repository at this point in the history
- when sticky is active it messes up the mega menu links as it doesn't
  respect the z-index
  • Loading branch information
ichim-david committed Jun 10, 2022
1 parent 24355d0 commit 1d7af95
Showing 1 changed file with 30 additions and 26 deletions.
56 changes: 30 additions & 26 deletions src/ui/Header/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,28 @@ const TopDropdownMenu = ({
);
};

const useScrollingUp = () => {
let prevScroll;

if (process.browser) {
prevScroll = window.pageYOffset;
}
const [scrollingUp, setScrollingUp] = React.useState(false);
const handleScroll = () => {
const currScroll = window.pageYOffset;
const isScrolled = prevScroll > currScroll;
setScrollingUp(isScrolled);
prevScroll = currScroll;
};
React.useEffect(() => {
window.addEventListener('scroll', handleScroll, { passive: true });
return () => {
window.removeEventListener('scroll', handleScroll, { passive: true });
};
});
return scrollingUp;
};
// disable sticky until it's more stable
// const useScrollingUp = () => {
// let prevScroll;
//
// if (process.browser) {
// prevScroll = window.pageYOffset;
// }
// const [scrollingUp, setScrollingUp] = React.useState(false);
// const handleScroll = () => {
// const currScroll = window.pageYOffset;
// const isScrolled = prevScroll > currScroll;
// setScrollingUp(isScrolled);
// prevScroll = currScroll;
// };
// React.useEffect(() => {
// window.addEventListener('scroll', handleScroll, { passive: true });
// return () => {
// window.removeEventListener('scroll', handleScroll, { passive: true });
// };
// });
// return scrollingUp;
// };

const Main = ({
logo,
Expand Down Expand Up @@ -143,17 +144,20 @@ const Main = ({
// }
// }, [searchIsActive, burger, menuIsActive]);

const isScrollingUp = useScrollingUp();

const node = React.useRef();
const searchButtonRef = React.useRef();
const mobileMenuBurgerRef = React.useRef();

// disable sticky setting until feature is more stable
// const isScrollingUp = useScrollingUp();
// <div
// className={`main bar ${transparency ? 'transparency' : ''} ${
// isScrollingUp ? 'sticky' : ''
// }`}
// >
return (
<div
className={`main bar ${transparency ? 'transparency' : ''} ${
isScrollingUp ? 'sticky' : ''
}`}
className={`main bar ${transparency ? 'transparency' : ''}`}
ref={node}
>
<Container>
Expand Down

0 comments on commit 1d7af95

Please sign in to comment.