From f741ba382dcd62cb14d793d2323b0bb08ee7ee26 Mon Sep 17 00:00:00 2001 From: Alex P Date: Fri, 24 Feb 2017 15:23:29 -0800 Subject: [PATCH] Resize window when enter / exit presentation mode --- ui/src/shared/constants/index.js | 2 +- ui/src/shared/middleware/resizeLayout.js | 10 ++++++++++ ui/src/store/configureStore.js | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 ui/src/shared/middleware/resizeLayout.js diff --git a/ui/src/shared/constants/index.js b/ui/src/shared/constants/index.js index da53f8e2a..6b0d7cb60 100644 --- a/ui/src/shared/constants/index.js +++ b/ui/src/shared/constants/index.js @@ -468,5 +468,5 @@ export const STROKE_WIDTH = { light: 1.5, }; -export const PRESENTATION_MODE_ANIMATION_DELAY = 250 // In milliseconds. +export const PRESENTATION_MODE_ANIMATION_DELAY = 0 // In milliseconds. export const PRESENTATION_MODE_NOTIFICATION_DELAY = 2000 // In milliseconds. diff --git a/ui/src/shared/middleware/resizeLayout.js b/ui/src/shared/middleware/resizeLayout.js new file mode 100644 index 000000000..cb5608138 --- /dev/null +++ b/ui/src/shared/middleware/resizeLayout.js @@ -0,0 +1,10 @@ +// Trigger resize event to relayout the React Layout plugin + +export default function resizeLayout() { + return next => action => { + next(action); + if (action.type === 'ENABLE_PRESENTATION_MODE' || action.type === 'DISABLE_PRESENTATION_MODE') { + window.dispatchEvent(new Event('resize')); + } + } +} \ No newline at end of file diff --git a/ui/src/store/configureStore.js b/ui/src/store/configureStore.js index 85b4a6e11..44b03fa66 100644 --- a/ui/src/store/configureStore.js +++ b/ui/src/store/configureStore.js @@ -2,6 +2,7 @@ import {createStore, applyMiddleware, compose} from 'redux'; import {combineReducers} from 'redux'; import thunkMiddleware from 'redux-thunk'; import makeQueryExecuter from 'src/shared/middleware/queryExecuter'; +import resizeLayout from 'src/shared/middleware/resizeLayout'; import * as dataExplorerReducers from 'src/data_explorer/reducers'; import * as sharedReducers from 'src/shared/reducers'; import rulesReducer from 'src/kapacitor/reducers/rules'; @@ -20,7 +21,7 @@ const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; export default function configureStore(initialState) { const createPersistentStore = composeEnhancers( persistStateEnhancer(), - applyMiddleware(thunkMiddleware, makeQueryExecuter()), + applyMiddleware(thunkMiddleware, makeQueryExecuter(), resizeLayout), )(createStore);