Skip to content
Snippets Groups Projects
Commit 8336ce55 authored by Chris Beer's avatar Chris Beer
Browse files

Cascade window positions in elastic mode; fixes #2122

parent 3e71fa16
Branches
Tags
No related merge requests found
......@@ -18,8 +18,8 @@ describe('window actions', () => {
manifestId: null,
maximized: false,
rangeId: null,
x: 2700,
y: 2700,
x: 2760,
y: 2760,
sideBarPanel: 'info',
width: 400,
height: 400,
......@@ -31,7 +31,19 @@ describe('window actions', () => {
{ position: 'far-bottom', content: 'thumbnail_navigation' },
],
};
const action = actions.addWindow(options);
const mockState = {
windows: { a: {}, b: {} },
};
const mockDispatch = jest.fn(() => ({}));
const mockGetState = jest.fn(() => mockState);
const thunk = actions.addWindow(options);
thunk(mockDispatch, mockGetState);
const action = mockDispatch.mock.calls[0][0];
expect(action).toMatchObject(expectedAction);
expect(action.window.companionWindowIds.length).toEqual(2);
expect(action.window.companionWindowIds[0]).toEqual(action.companionWindows[0].id);
......
......@@ -18,6 +18,10 @@ export function focusWindow(windowId) {
* @memberof ActionCreators
*/
export function addWindow(options) {
return (dispatch, getState) => {
const { windows } = getState();
const numWindows = Object.keys(windows).length;
const cwDefault = `cw-${uuid()}`;
const cwThumbs = `cw-${uuid()}`;
const defaultOptions = {
......@@ -29,21 +33,23 @@ export function addWindow(options) {
thumbnailNavigationId: cwThumbs,
width: 400,
height: 400,
x: 2700,
y: 2700,
x: 2700 + (Math.floor(numWindows / 10) * 50 + (numWindows * 30) % 300),
y: 2700 + ((numWindows * 30) % 300),
companionWindowIds: [cwDefault, cwThumbs],
sideBarPanel: 'info',
rotation: null,
view: 'single',
maximized: false,
};
return {
dispatch({
type: ActionTypes.ADD_WINDOW,
window: { ...defaultOptions, ...options },
companionWindows: [
{ id: cwDefault, position: 'left', content: 'info' },
{ id: cwThumbs, position: options.thumbnailNavigationPosition || 'far-bottom', content: 'thumbnail_navigation' },
],
});
};
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment