diff --git a/src/layouts/Header.js b/src/layouts/Header.js index cb3b2d7c47c4aac62c5491968d832665419d2d44..8ad15c18ab0b3fb4784b90bc2e92b0a1be545ab2 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 ? (