Commit 08a59602 authored by ι™ˆεΈ…'s avatar ι™ˆεΈ…

fix #2168 When auto-hide is off, the header is displayed.

parent 555d8984
...@@ -15,6 +15,15 @@ class HeaderView extends PureComponent { ...@@ -15,6 +15,15 @@ class HeaderView extends PureComponent {
visible: true, visible: true,
}; };
static getDerivedStateFromProps(props, state) {
if (!props.autoHideHeader && !state.visible) {
return {
visible: true,
};
}
return null;
}
componentDidMount() { componentDidMount() {
document.addEventListener('scroll', this.handScroll, { passive: true }); document.addEventListener('scroll', this.handScroll, { passive: true });
} }
...@@ -87,12 +96,12 @@ class HeaderView extends PureComponent { ...@@ -87,12 +96,12 @@ class HeaderView extends PureComponent {
this.scrollTop = scrollTop; this.scrollTop = scrollTop;
return; return;
} }
if (scrollTop > 400 && visible) { if (scrollTop > 300 && visible) {
this.setState({ this.setState({
visible: false, visible: false,
}); });
} }
if (scrollTop < 400 && !visible) { if (scrollTop < 300 && !visible) {
this.setState({ this.setState({
visible: true, visible: true,
}); });
...@@ -109,11 +118,9 @@ class HeaderView extends PureComponent { ...@@ -109,11 +118,9 @@ class HeaderView extends PureComponent {
const { navTheme, layout, fixedHeader } = setting; const { navTheme, layout, fixedHeader } = setting;
const { visible } = this.state; const { visible } = this.state;
const isTop = layout === 'topmenu'; const isTop = layout === 'topmenu';
const width = this.getHeadWidth();
const HeaderDom = visible ? ( const HeaderDom = visible ? (
<Header <Header style={{ padding: 0, width }} className={fixedHeader ? styles.fixedHeader : ''}>
style={{ padding: 0, width: this.getHeadWidth() }}
className={fixedHeader ? styles.fixedHeader : ''}
>
{isTop && !isMobile ? ( {isTop && !isMobile ? (
<TopNavHeader <TopNavHeader
theme={navTheme} theme={navTheme}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment