Spaces:
Running
Running
File size: 846 Bytes
f2bee8a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
const UPDATE_METRICS = 'scratch-gui/workspace-metrics/UPDATE_METRICS';
const initialState = {
targets: {}
};
const reducer = function (state, action) {
if (typeof state === 'undefined') state = initialState;
switch (action.type) {
case UPDATE_METRICS:
return Object.assign({}, state, {
targets: Object.assign({}, state.targets, {
[action.targetID]: {
scrollX: action.scrollX,
scrollY: action.scrollY,
scale: action.scale
}
})
});
default:
return state;
}
};
const updateMetrics = function (metrics) {
return {
type: UPDATE_METRICS,
...metrics
};
};
export {
reducer as default,
initialState as workspaceMetricsInitialState,
updateMetrics
};
|