fix(Panes): Height should always take full screen
This commit is contained in:
@ -7,7 +7,6 @@ import {
|
|||||||
panesSelector,
|
panesSelector,
|
||||||
panesByNameSelector,
|
panesByNameSelector,
|
||||||
panesMounted,
|
panesMounted,
|
||||||
heightSelector,
|
|
||||||
widthSelector
|
widthSelector
|
||||||
} from './redux';
|
} from './redux';
|
||||||
import Pane from './Pane.jsx';
|
import Pane from './Pane.jsx';
|
||||||
@ -16,9 +15,8 @@ import Divider from './Divider.jsx';
|
|||||||
const mapStateToProps = createSelector(
|
const mapStateToProps = createSelector(
|
||||||
panesSelector,
|
panesSelector,
|
||||||
panesByNameSelector,
|
panesByNameSelector,
|
||||||
heightSelector,
|
|
||||||
widthSelector,
|
widthSelector,
|
||||||
(panes, panesByName, height) => {
|
(panes, panesByName) => {
|
||||||
let lastDividerPosition = 0;
|
let lastDividerPosition = 0;
|
||||||
return {
|
return {
|
||||||
panes: panes
|
panes: panes
|
||||||
@ -33,8 +31,7 @@ const mapStateToProps = createSelector(
|
|||||||
left: index === 0 ? 0 : left,
|
left: index === 0 ? 0 : left,
|
||||||
right: index + 1 === numOfPanes ? 0 : 100 - dividerLeft
|
right: index + 1 === numOfPanes ? 0 : 100 - dividerLeft
|
||||||
};
|
};
|
||||||
}, {}),
|
}, {})
|
||||||
height
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -42,7 +39,6 @@ const mapStateToProps = createSelector(
|
|||||||
const mapDispatchToProps = { panesMounted };
|
const mapDispatchToProps = { panesMounted };
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
height: PropTypes.number.isRequired,
|
|
||||||
panes: PropTypes.array,
|
panes: PropTypes.array,
|
||||||
panesMounted: PropTypes.func.isRequired,
|
panesMounted: PropTypes.func.isRequired,
|
||||||
render: PropTypes.func.isRequired
|
render: PropTypes.func.isRequired
|
||||||
@ -83,9 +79,8 @@ export class Panes extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { height } = this.props;
|
|
||||||
const outerStyle = {
|
const outerStyle = {
|
||||||
height,
|
height: '100%',
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
width: '100%'
|
width: '100%'
|
||||||
};
|
};
|
||||||
|
@ -27,11 +27,7 @@ export const types = createTypes([
|
|||||||
'dividerClicked',
|
'dividerClicked',
|
||||||
'dividerMoved',
|
'dividerMoved',
|
||||||
'mouseReleased',
|
'mouseReleased',
|
||||||
'windowResized',
|
'windowResized'
|
||||||
|
|
||||||
// commands
|
|
||||||
'hidePane',
|
|
||||||
'updateNavHeight'
|
|
||||||
], ns);
|
], ns);
|
||||||
|
|
||||||
export const panesMapUpdated = createAction(
|
export const panesMapUpdated = createAction(
|
||||||
@ -49,24 +45,14 @@ export const dividerMoved = createAction(types.dividerMoved);
|
|||||||
export const mouseReleased = createAction(types.mouseReleased);
|
export const mouseReleased = createAction(types.mouseReleased);
|
||||||
export const windowResized = createAction(types.windowResized);
|
export const windowResized = createAction(types.windowResized);
|
||||||
|
|
||||||
// commands
|
|
||||||
export const hidePane = createAction(types.hidePane);
|
|
||||||
export const updateNavHeight = createAction(types.updateNavHeight);
|
|
||||||
|
|
||||||
const defaultState = {
|
const defaultState = {
|
||||||
height: 600,
|
|
||||||
width: 800,
|
width: 800,
|
||||||
navHeight: 50,
|
|
||||||
panes: [],
|
panes: [],
|
||||||
panesByName: {},
|
panesByName: {},
|
||||||
panesMap: {},
|
panesMap: {},
|
||||||
pressedDivider: null
|
pressedDivider: null
|
||||||
};
|
};
|
||||||
export const getNS = state => state[ns];
|
export const getNS = state => state[ns];
|
||||||
export const heightSelector = state => {
|
|
||||||
const { navHeight, height } = getNS(state);
|
|
||||||
return height - navHeight;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const panesSelector = state => getNS(state).panes;
|
export const panesSelector = state => getNS(state).panes;
|
||||||
export const panesByNameSelector = state => getNS(state).panesByName;
|
export const panesByNameSelector = state => getNS(state).panesByName;
|
||||||
@ -142,9 +128,8 @@ export default function createPanesAspects({ createPanesMap }) {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
[types.mouseReleased]: state => ({ ...state, pressedDivider: null }),
|
[types.mouseReleased]: state => ({ ...state, pressedDivider: null }),
|
||||||
[types.windowResized]: (state, { payload: { height, width } }) => ({
|
[types.windowResized]: (state, { payload: { width } }) => ({
|
||||||
...state,
|
...state,
|
||||||
height,
|
|
||||||
width
|
width
|
||||||
}),
|
}),
|
||||||
// used to clear bin buttons
|
// used to clear bin buttons
|
||||||
@ -153,10 +138,6 @@ export default function createPanesAspects({ createPanesMap }) {
|
|||||||
panes: [],
|
panes: [],
|
||||||
panesByName: {},
|
panesByName: {},
|
||||||
pressedDivider: null
|
pressedDivider: null
|
||||||
}),
|
|
||||||
[types.updateNavHeight]: (state, { payload: navHeight }) => ({
|
|
||||||
...state,
|
|
||||||
navHeight
|
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
defaultState
|
defaultState
|
||||||
|
@ -10,12 +10,10 @@ export default function windowEpic(actions, _, { window }) {
|
|||||||
return actions::ofType(types.panesMounted)
|
return actions::ofType(types.panesMounted)
|
||||||
.switchMap(() => {
|
.switchMap(() => {
|
||||||
return Observable.fromEvent(window, 'resize', () => windowResized({
|
return Observable.fromEvent(window, 'resize', () => windowResized({
|
||||||
width: window.innerWidth,
|
width: window.innerWidth
|
||||||
height: window.innerHeight
|
|
||||||
}))
|
}))
|
||||||
.startWith(windowResized({
|
.startWith(windowResized({
|
||||||
width: window.innerWidth,
|
width: window.innerWidth
|
||||||
height: window.innerHeight
|
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user