From e734665feaca759fce0722f002c73c91ea627811 Mon Sep 17 00:00:00 2001 From: Hugo Lextrait Date: Thu, 23 Mar 2023 14:38:49 +0100 Subject: [PATCH] add breackpoint variable --- src/front/Components/DesignSystem/Header/index.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/front/Components/DesignSystem/Header/index.tsx b/src/front/Components/DesignSystem/Header/index.tsx index 403882ad..b8c176be 100644 --- a/src/front/Components/DesignSystem/Header/index.tsx +++ b/src/front/Components/DesignSystem/Header/index.tsx @@ -28,6 +28,7 @@ type IState = { export default class Header extends React.Component { private onScrollYDirectionChange = () => { }; private onWindowResize = () => { }; + private headerBreakpoint = 1300; constructor(props: IProps) { super(props); @@ -87,7 +88,7 @@ export default class Header extends React.Component { private visibility(scrollYDirection: number) { let open: IState["open"] = EHeaderOpeningState.OPEN; - if (window.scrollY > 50 && scrollYDirection < 0 && Math.abs(scrollYDirection) > 8) { + if (window.scrollY > 50 && scrollYDirection < 0 && Math.abs(scrollYDirection) > 8 && window.innerWidth < this.headerBreakpoint) { open = EHeaderOpeningState.CLOSED; this.closeBurgerMenu(); this.closeNotificationMenu(); @@ -97,10 +98,8 @@ export default class Header extends React.Component { } private onResize(window: Window) { - if (window.innerWidth === 1300) { - this.setState({ isBurgerMenuOpen: false }); - this.setState({ isProfileMenuOpen: false }); - } + if(window.innerWidth > this.headerBreakpoint && this.state.isBurgerMenuOpen) this.setState({ isBurgerMenuOpen: false }); + if (window.innerWidth < this.headerBreakpoint && this.state.isProfileMenuOpen) this.setState({ isProfileMenuOpen: false }); } private openBurgerMenu() {