提交 08a59602 编写于 作者: 陈帅

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

上级 555d8984
......@@ -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 ? (
<Header
style={{ padding: 0, width: this.getHeadWidth() }}
className={fixedHeader ? styles.fixedHeader : ''}
>
<Header style={{ padding: 0, width }} className={fixedHeader ? styles.fixedHeader : ''}>
{isTop && !isMobile ? (
<TopNavHeader
theme={navTheme}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册