Fix window height adjustment during dev
This commit is contained in:
@@ -19,7 +19,7 @@ import {
|
||||
saveToColdStorage
|
||||
} from './cold-reload';
|
||||
|
||||
Rx.config.longStackSupport = !!debug.enabled;
|
||||
const isDev = Rx.config.longStackSupport = !!debug.enabled;
|
||||
|
||||
const log = debug('fcc:client');
|
||||
const hotReloadTimeout = 5000;
|
||||
@@ -39,6 +39,7 @@ const devTools = window.devToolsExtension ? window.devToolsExtension() : f => f;
|
||||
const shouldRouterListenForReplays = !!window.devToolsExtension;
|
||||
|
||||
const sagaOptions = {
|
||||
isDev,
|
||||
window,
|
||||
document: window.document,
|
||||
location: window.location
|
||||
|
@@ -2,5 +2,12 @@ import errSaga from './err-saga';
|
||||
import titleSaga from './title-saga';
|
||||
import localStorageSaga from './local-storage-saga';
|
||||
import hardGoToSaga from './hard-go-to-saga';
|
||||
import windowSaga from './window-saga';
|
||||
|
||||
export default [ errSaga, titleSaga, localStorageSaga, hardGoToSaga ];
|
||||
export default [
|
||||
errSaga,
|
||||
titleSaga,
|
||||
localStorageSaga,
|
||||
hardGoToSaga,
|
||||
windowSaga
|
||||
];
|
||||
|
34
client/sagas/window-saga.js
Normal file
34
client/sagas/window-saga.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import { Observable } from 'rx';
|
||||
import { initWindowHeight } from '../../common/app/redux/types';
|
||||
import { updateWindowHeight } from '../../common/app/redux/actions';
|
||||
|
||||
function getWindowSize(document, window) {
|
||||
const body = document.getElementsByTagName('body')[0];
|
||||
return window.innerHeight ||
|
||||
document.docElement.clientHeight ||
|
||||
body.clientHeight ||
|
||||
0;
|
||||
}
|
||||
|
||||
function listenForResize(document, window) {
|
||||
return Observable.fromEvent(window, 'resize')
|
||||
.debounce(250)
|
||||
.startWith({})
|
||||
.map(() => getWindowSize(document, window));
|
||||
}
|
||||
|
||||
export default function windowSaga(
|
||||
action$,
|
||||
getState,
|
||||
{ isDev, document, window }
|
||||
) {
|
||||
return action$
|
||||
.filter(({ type }) => type === initWindowHeight)
|
||||
.flatMap(() => {
|
||||
if (isDev) {
|
||||
return listenForResize(document, window);
|
||||
}
|
||||
return Observable.just(getWindowSize(document, window));
|
||||
})
|
||||
.map(updateWindowHeight);
|
||||
}
|
Reference in New Issue
Block a user