Moving the underlying map out of the slippy component and handling window resize events.

This commit is contained in:
vdv committed 2022-09-12 15:10:12 +02:00
1 parent 2207ae1652
commit 75b4bb2e2b
9 files changed
+184 -113

No files matched your search

+2 -1
View File
@@ -1,9 +1,10 @@
import { configureStore } from '@reduxjs/toolkit';
import slippyReducer from './slippy';
import mapReducer from './map';
const store = configureStore({
reducer: { slippy: slippyReducer},
reducer: { slippy: slippyReducer, map: mapReducer },
});
export default store;
+30
View File
@@ -0,0 +1,30 @@
import { createSlice } from '@reduxjs/toolkit';
export interface MapState {
viewport: {
width: number;
height: number;
};
}
const initialMapState: MapState = {
viewport: {
width: window.innerWidth,
height: window.innerHeight,
},
};
const mapSlice = createSlice({
name: 'map',
initialState: initialMapState,
reducers: {
resize: (state) => {
state.viewport.height = window.innerHeight;
state.viewport.width = window.innerWidth;
},
},
});
export const mapActions = mapSlice.actions;
export default mapSlice.reducer;