diff options
| author | Georgios Andreadis <info@gandreadis.com> | 2020-07-22 14:07:39 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-08-24 19:48:18 +0200 |
| commit | 92ce9387f5c3ce54b4077ef6a5f604fc2cfe6ade (patch) | |
| tree | 90432dbd06a13d300f8307dea342f4639c9c57e7 /frontend/src/store | |
| parent | ae8f03d514ba0982a34b96f1e29e262ca6048a19 (diff) | |
| parent | 8739a156b75ba96e15d1bb19b08ca829c1eb01e8 (diff) | |
Merge pull request #12 from atlarge-research/feature/scenario-plots
Plotting of portfolio results
Diffstat (limited to 'frontend/src/store')
| -rw-r--r-- | frontend/src/store/middlewares/dummy-middleware.js | 2 | ||||
| -rw-r--r-- | frontend/src/store/middlewares/viewport-adjustment.js | 27 |
2 files changed, 8 insertions, 21 deletions
diff --git a/frontend/src/store/middlewares/dummy-middleware.js b/frontend/src/store/middlewares/dummy-middleware.js index ed5670c5..5ba35691 100644 --- a/frontend/src/store/middlewares/dummy-middleware.js +++ b/frontend/src/store/middlewares/dummy-middleware.js @@ -1,3 +1,3 @@ -export const dummyMiddleware = store => next => action => { +export const dummyMiddleware = (store) => (next) => (action) => { next(action) } diff --git a/frontend/src/store/middlewares/viewport-adjustment.js b/frontend/src/store/middlewares/viewport-adjustment.js index 84f2a3e9..b4472c54 100644 --- a/frontend/src/store/middlewares/viewport-adjustment.js +++ b/frontend/src/store/middlewares/viewport-adjustment.js @@ -9,7 +9,7 @@ import { } from '../../components/app/map/MapConstants' import { calculateRoomListBounds } from '../../util/tile-calculations' -export const viewportAdjustmentMiddleware = store => next => action => { +export const viewportAdjustmentMiddleware = (store) => (next) => (action) => { const state = store.getState() let topologyId = '-1' @@ -17,21 +17,15 @@ export const viewportAdjustmentMiddleware = store => next => action => { if (action.type === SET_CURRENT_TOPOLOGY && action.topologyId !== '-1') { topologyId = action.topologyId mapDimensions = state.map.dimensions - } else if ( - action.type === SET_MAP_DIMENSIONS && - state.currentTopologyId !== '-1' - ) { + } else if (action.type === SET_MAP_DIMENSIONS && state.currentTopologyId !== '-1') { topologyId = state.currentTopologyId mapDimensions = { width: action.width, height: action.height } } if (topologyId !== '-1') { const roomIds = state.objects.topology[topologyId].roomIds - const rooms = roomIds.map(id => Object.assign({}, state.objects.room[id])) - rooms.forEach( - room => - (room.tiles = room.tileIds.map(tileId => state.objects.tile[tileId])), - ) + const rooms = roomIds.map((id) => Object.assign({}, state.objects.room[id])) + rooms.forEach((room) => (room.tiles = room.tileIds.map((tileId) => state.objects.tile[tileId]))) let hasNoTiles = true for (let i in rooms) { @@ -42,11 +36,7 @@ export const viewportAdjustmentMiddleware = store => next => action => { } if (!hasNoTiles) { - const viewportParams = calculateParametersToZoomInOnRooms( - rooms, - mapDimensions.width, - mapDimensions.height, - ) + const viewportParams = calculateParametersToZoomInOnRooms(rooms, mapDimensions.width, mapDimensions.height) store.dispatch(setMapPosition(viewportParams.newX, viewportParams.newY)) store.dispatch(setMapScale(viewportParams.newScale)) } @@ -75,11 +65,8 @@ function calculateNewScale(bounds, mapWidth, mapHeight) { const width = bounds.max.x - bounds.min.x const height = bounds.max.y - bounds.min.y - const scaleX = - (mapWidth - 2 * SIDEBAR_WIDTH) / - (width * TILE_SIZE_IN_PIXELS + 2 * VIEWPORT_PADDING) - const scaleY = - mapHeight / (height * TILE_SIZE_IN_PIXELS + 2 * VIEWPORT_PADDING) + const scaleX = (mapWidth - 2 * SIDEBAR_WIDTH) / (width * TILE_SIZE_IN_PIXELS + 2 * VIEWPORT_PADDING) + const scaleY = mapHeight / (height * TILE_SIZE_IN_PIXELS + 2 * VIEWPORT_PADDING) const newScale = Math.min(scaleX, scaleY) return Math.min(Math.max(MAP_MIN_SCALE, newScale), MAP_MAX_SCALE) |
