aboutsummaryrefslogtreecommitdiff
path: root/src/content/reducers
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/reducers')
-rw-r--r--src/content/reducers/index.js3
-rw-r--r--src/content/reducers/mark.js25
2 files changed, 27 insertions, 1 deletions
diff --git a/src/content/reducers/index.js b/src/content/reducers/index.js
index 6e6a147..bf612a3 100644
--- a/src/content/reducers/index.js
+++ b/src/content/reducers/index.js
@@ -4,7 +4,8 @@ import find from './find';
import setting from './setting';
import input from './input';
import followController from './follow-controller';
+import mark from './mark';
export default combineReducers({
- addon, find, setting, input, followController,
+ addon, find, setting, input, followController, mark,
});
diff --git a/src/content/reducers/mark.js b/src/content/reducers/mark.js
new file mode 100644
index 0000000..2c96cc5
--- /dev/null
+++ b/src/content/reducers/mark.js
@@ -0,0 +1,25 @@
+import actions from 'content/actions';
+
+const defaultState = {
+ setMode: false,
+ jumpMode: false,
+ marks: {},
+};
+
+export default function reducer(state = defaultState, action = {}) {
+ switch (action.type) {
+ case actions.MARK_START_SET:
+ return { ...state, setMode: true };
+ case actions.MARK_START_JUMP:
+ return { ...state, jumpMode: true };
+ case actions.MARK_CANCEL:
+ return { ...state, setMode: false, jumpMode: false };
+ case actions.MARK_SET_LOCAL: {
+ let marks = { ...state.marks };
+ marks[action.key] = { x: action.x, y: action.y };
+ return { ...state, setMode: false, marks };
+ }
+ default:
+ return state;
+ }
+}