From 6287dc777f7a4760230e36b8751c76d5022af7d5 Mon Sep 17 00:00:00 2001
From: Alex P <thealexpaxton@gmail.com>
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 da53f8e2af..6b0d7cb600 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 0000000000..cb5608138c
--- /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 85b4a6e11a..44b03fa66c 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);