From 08a596027ee77b29dc96c0382544df94bd4f09e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Thu, 6 Sep 2018 10:17:27 +0800 Subject: [PATCH] fix #2168 When auto-hide is off, the header is displayed. --- src/layouts/Header.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/layouts/Header.js b/src/layouts/Header.js index cb3b2d7c..8ad15c18 100644 --- a/src/layouts/Header.js +++ b/src/layouts/Header.js @@ -15,6 +15,15 @@ class HeaderView extends PureComponent { visible: true, }; + static getDerivedStateFromProps(props, state) { + if (!props.autoHideHeader && !state.visible) { + return { + visible: true, + }; + } + return null; + } + componentDidMount() { document.addEventListener('scroll', this.handScroll, { passive: true }); } @@ -87,12 +96,12 @@ class HeaderView extends PureComponent { this.scrollTop = scrollTop; return; } - if (scrollTop > 400 && visible) { + if (scrollTop > 300 && visible) { this.setState({ visible: false, }); } - if (scrollTop < 400 && !visible) { + if (scrollTop < 300 && !visible) { this.setState({ visible: true, }); @@ -109,11 +118,9 @@ class HeaderView extends PureComponent { const { navTheme, layout, fixedHeader } = setting; const { visible } = this.state; const isTop = layout === 'topmenu'; + const width = this.getHeadWidth(); const HeaderDom = visible ? ( -
+
{isTop && !isMobile ? (