From 17feda3a9b98e1bf07a6735cbc4642986dfe9e2a Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 27 Oct 2017 20:06:50 +0800 Subject: [PATCH] dispatch window resize event when menu collapse --- src/components/FooterToolbar/index.js | 28 +-------------------------- src/layouts/BasicLayout.js | 3 +++ 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/src/components/FooterToolbar/index.js b/src/components/FooterToolbar/index.js index 81a8257f..62527e9e 100644 --- a/src/components/FooterToolbar/index.js +++ b/src/components/FooterToolbar/index.js @@ -1,39 +1,13 @@ import React, { Component } from 'react'; -import PropTypes from 'prop-types'; import classNames from 'classnames'; import styles from './index.less'; export default class FooterToolbar extends Component { - static contextTypes = { - layoutCollapsed: PropTypes.bool, - }; - state = { - width: '', - }; - componentDidMount() { - this.syncWidth(); - } - componentWillReceiveProps() { - this.syncWidth(); - } - syncWidth() { - const sider = document.querySelectorAll('.ant-layout-sider')[0]; - if (sider) { - this.setState({ - width: `calc(100% - ${sider.style.width})`, - }); - } - } render() { - const { children, style, className, extra, ...restProps } = this.props; + const { children, className, extra, ...restProps } = this.props; return (
{extra}
diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index 118c4323..bfe2a80e 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -170,6 +170,9 @@ class BasicLayout extends React.PureComponent { type: 'global/changeLayoutCollapsed', payload: !collapsed, }); + const event = document.createEvent('HTMLEvents'); + event.initEvent('resize', true, false); + window.dispatchEvent(event); } handleNoticeClear = (type) => { message.success(`清空了${type}`); -- GitLab