mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2025-01-10 06:32:07 -05:00
26 lines
639 B
JavaScript
26 lines
639 B
JavaScript
|
const CHANGE_ERASER_SIZE = 'scratch-paint/tools/CHANGE_ERASER_SIZE';
|
||
|
const initialState = {brushSize: 20};
|
||
|
|
||
|
const reducer = function (state, action) {
|
||
|
if (typeof state === 'undefined') state = initialState;
|
||
|
switch (action.type) {
|
||
|
case CHANGE_ERASER_SIZE:
|
||
|
return {brushSize: Math.max(1, action.brushSize)};
|
||
|
default:
|
||
|
return state;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
// Action creators ==================================
|
||
|
reducer.changeBrushSize = function (brushSize) {
|
||
|
return {
|
||
|
type: CHANGE_ERASER_SIZE,
|
||
|
brushSize: brushSize,
|
||
|
meta: {
|
||
|
throttle: 30
|
||
|
}
|
||
|
};
|
||
|
};
|
||
|
|
||
|
module.exports = reducer;
|