aboutsummaryrefslogtreecommitdiff
path: root/src/components/media_modal/media_modal.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/media_modal/media_modal.js')
-rw-r--r--src/components/media_modal/media_modal.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/components/media_modal/media_modal.js b/src/components/media_modal/media_modal.js
index f3d381ee..8f67db2b 100644
--- a/src/components/media_modal/media_modal.js
+++ b/src/components/media_modal/media_modal.js
@@ -4,6 +4,7 @@ import Modal from '../modal/modal.vue'
import fileTypeService from '../../services/file_type/file_type.service.js'
import GestureService from '../../services/gesture_service/gesture_service'
import Flash from 'src/components/flash/flash.vue'
+import Vuex from 'vuex'
import { library } from '@fortawesome/fontawesome-svg-core'
import {
faChevronLeft,
@@ -17,6 +18,8 @@ library.add(
faCircleNotch
)
+const onlyXAxis = ([x, y]) => [x, 0]
+
const MediaModal = {
components: {
StillImage,
@@ -50,6 +53,15 @@ const MediaModal = {
},
type () {
return this.currentMedia ? this.getType(this.currentMedia) : null
+ },
+ scaling () {
+ return this.$store.state.mediaViewer.swipeScaler.scaling
+ },
+ offsets () {
+ return this.$store.state.mediaViewer.swipeScaler.offsets
+ },
+ transform () {
+ return `scale(${this.scaling}, ${this.scaling}) translate(${this.offsets[0]}px, ${this.offsets[1]}px)`
}
},
created () {
@@ -57,6 +69,8 @@ const MediaModal = {
direction: GestureService.DIRECTION_LEFT,
callbackPositive: this.goNext,
callbackNegative: this.goPrev,
+ swipePreviewCallback: this.handleSwipePreview,
+ swipeEndCallback: this.handleSwipeEnd,
threshold: 50
})
},
@@ -99,6 +113,18 @@ const MediaModal = {
onImageLoaded () {
this.loading = false
},
+ handleSwipePreview (offsets) {
+ this.$store.dispatch('swipeScaler/apply', { offsets: onlyXAxis(offsets) })
+ },
+ handleSwipeEnd (sign) {
+ if (sign === 0) {
+ this.$store.dispatch('swipeScaler/revert')
+ } else if (sign > 0) {
+ this.goNext()
+ } else {
+ this.goPrev()
+ }
+ },
handleKeyupEvent (e) {
if (this.showing && e.keyCode === 27) { // escape
this.hide()