diff options
| author | Tusooa Zhu <tusooa@kazv.moe> | 2021-08-02 19:11:59 -0400 |
|---|---|---|
| committer | Tusooa Zhu <tusooa@kazv.moe> | 2022-03-13 12:00:44 -0400 |
| commit | 29cd8fbd3bd9f936d2639a2edd773e1245b0b5a5 (patch) | |
| tree | 6058c29bd3242bd50a1333b5fb2e2ecb07fe1947 /src/modules/media_viewer.js | |
| parent | a36673a6a8cace69979605f72bcc4d7a9d439814 (diff) | |
Add swipe-click handler to media modal
Now swiping will correctly change the current media, and with a good
preview. Clicking without swiping closes the overlay.
Diffstat (limited to 'src/modules/media_viewer.js')
| -rw-r--r-- | src/modules/media_viewer.js | 56 |
1 files changed, 1 insertions, 55 deletions
diff --git a/src/modules/media_viewer.js b/src/modules/media_viewer.js index ddcccb79..0299b04e 100644 --- a/src/modules/media_viewer.js +++ b/src/modules/media_viewer.js @@ -26,67 +26,13 @@ const mediaViewer = { return supportedTypes.has(type) }) commit('setMedia', media) - dispatch('swipeScaler/reset') }, - setCurrentMedia ({ commit, state, dispatch }, current) { + setCurrentMedia ({ commit, state }, current) { const index = state.media.indexOf(current) commit('setCurrentMedia', index || 0) - dispatch('swipeScaler/reset') }, closeMediaViewer ({ commit, dispatch }) { commit('close') - dispatch('swipeScaler/reset') - } - }, - modules: { - swipeScaler: { - namespaced: true, - - state: { - origOffsets: [0, 0], - offsets: [0, 0], - origScaling: 1, - scaling: 1 - }, - - mutations: { - reset (state) { - state.origOffsets = [0, 0] - state.offsets = [0, 0] - state.origScaling = 1 - state.scaling = 1 - }, - applyOffsets (state, { offsets }) { - state.offsets = state.origOffsets.map((k, n) => k + offsets[n]) - }, - applyScaling (state, { scaling }) { - state.scaling = state.origScaling * scaling - }, - finish (state) { - state.origOffsets = [...state.offsets] - state.origScaling = state.scaling - }, - revert (state) { - state.offsets = [...state.origOffsets] - state.scaling = state.origScaling - } - }, - - actions: { - reset ({ commit }) { - commit('reset') - }, - apply ({ commit }, { offsets, scaling = 1 }) { - commit('applyOffsets', { offsets }) - commit('applyScaling', { scaling }) - }, - finish ({ commit }) { - commit('finish') - }, - revert ({ commit }) { - commit('revert') - } - } } } } |
