diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-10-13 22:15:16 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-13 22:15:16 +0900 |
commit | 8b72aac09af476e19da7e482e43769d47d1969b2 (patch) | |
tree | 7b5628784afc557e3c887e32c36e5bd49bac90d5 /src/content/reducers | |
parent | b09a4d1bae85eea537d80a5077cdd17d849cfaa5 (diff) | |
parent | 3c40b74a3e8d87ba310b46e24d6465d48766e3e8 (diff) |
Merge pull request #486 from ueokande/jump-marks
Support jump marks
Diffstat (limited to 'src/content/reducers')
-rw-r--r-- | src/content/reducers/index.js | 3 | ||||
-rw-r--r-- | src/content/reducers/mark.js | 25 |
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; + } +} |