penguinmod-editor-2 / src /reducers /workspace-metrics.js
soiz1's picture
Upload 2891 files
6bcb42f verified
raw
history blame contribute delete
846 Bytes
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
};