From 2fc0cb9fab9af5f4a9da2063cbe6f9caf2b1d9a9 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 27 Oct 2017 20:17:30 +0800 Subject: [PATCH] Add delay for resize --- src/layouts/BasicLayout.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index bfe2a80e..68171dbb 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -44,6 +44,9 @@ class BasicLayout extends React.PureComponent { type: 'user/fetchCurrent', }); } + componentWillUnmount() { + clearTimeout(this.resizeTimeout); + } onCollapse = (collapsed) => { this.props.dispatch({ type: 'global/changeLayoutCollapsed', @@ -170,9 +173,11 @@ class BasicLayout extends React.PureComponent { type: 'global/changeLayoutCollapsed', payload: !collapsed, }); - const event = document.createEvent('HTMLEvents'); - event.initEvent('resize', true, false); - window.dispatchEvent(event); + this.resizeTimeout = setTimeout(() => { + const event = document.createEvent('HTMLEvents'); + event.initEvent('resize', true, false); + window.dispatchEvent(event); + }, 600); } handleNoticeClear = (type) => { message.success(`清空了${type}`); -- GitLab