Only reload once viewport changes
This commit is contained in:
@@ -7,6 +7,7 @@ import createHistory from 'history/createBrowserHistory';
|
|||||||
import App from './components/App';
|
import App from './components/App';
|
||||||
import appReducer from './reducer';
|
import appReducer from './reducer';
|
||||||
import actions, { NAVIGATE } from './actions';
|
import actions, { NAVIGATE } from './actions';
|
||||||
|
import {isMobileViewport} from '../common/config'
|
||||||
|
|
||||||
// Remove .html and map / to index
|
// Remove .html and map / to index
|
||||||
const getPageNameFromPath = (path) => {
|
const getPageNameFromPath = (path) => {
|
||||||
@@ -37,10 +38,11 @@ const historyManager = store => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let reloadTimeout;
|
let reloadTimeout;
|
||||||
|
let wasMobileViewport = isMobileViewport();
|
||||||
window.addEventListener('resize', function () {
|
window.addEventListener('resize', function () {
|
||||||
clearTimeout(reloadTimeout);
|
clearTimeout(reloadTimeout);
|
||||||
reloadTimeout = setTimeout(() => {
|
reloadTimeout = setTimeout(() => {
|
||||||
window.location.reload();
|
if (wasMobileViewport != isMobileViewport()) window.location.reload();
|
||||||
}, 200);
|
}, 200);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user