forked from AkkomaGang/akkoma-fe
Add pan threshold
This commit is contained in:
parent
7d767f840b
commit
0421c06d47
|
@ -16,6 +16,8 @@ library.add(
|
||||||
)
|
)
|
||||||
|
|
||||||
const onlyXAxis = ([x, y]) => [x, 0]
|
const onlyXAxis = ([x, y]) => [x, 0]
|
||||||
|
const SCALING_RESET_MIN = 1.1
|
||||||
|
const SCALING_ENABLE_MOVE_THRESHOLD = 1
|
||||||
|
|
||||||
const MediaModal = {
|
const MediaModal = {
|
||||||
components: {
|
components: {
|
||||||
|
@ -90,11 +92,17 @@ const MediaModal = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleSwipePreview (offsets) {
|
handleSwipePreview (offsets) {
|
||||||
this.$store.dispatch('swipeScaler/apply', { offsets: onlyXAxis(offsets) })
|
this.$store.dispatch('swipeScaler/apply', {
|
||||||
|
offsets: this.scaling > SCALING_ENABLE_MOVE_THRESHOLD ? offsets : onlyXAxis(offsets)
|
||||||
|
})
|
||||||
},
|
},
|
||||||
handleSwipeEnd (sign) {
|
handleSwipeEnd (sign) {
|
||||||
|
if (this.scaling > SCALING_ENABLE_MOVE_THRESHOLD) {
|
||||||
|
this.$store.dispatch('swipeScaler/finish')
|
||||||
|
return
|
||||||
|
}
|
||||||
if (sign === 0) {
|
if (sign === 0) {
|
||||||
this.$store.dispatch('swipeScaler/revert')
|
this.$store.dispatch('swipeScaler/reset')
|
||||||
} else if (sign > 0) {
|
} else if (sign > 0) {
|
||||||
this.goNext()
|
this.goNext()
|
||||||
} else {
|
} else {
|
||||||
|
@ -106,7 +114,11 @@ const MediaModal = {
|
||||||
this.$store.dispatch('swipeScaler/apply', { offsets, scaling })
|
this.$store.dispatch('swipeScaler/apply', { offsets, scaling })
|
||||||
},
|
},
|
||||||
handlePinchEnd () {
|
handlePinchEnd () {
|
||||||
this.$store.dispatch('swipeScaler/finish')
|
if (this.scaling > SCALING_RESET_MIN) {
|
||||||
|
this.$store.dispatch('swipeScaler/finish')
|
||||||
|
} else {
|
||||||
|
this.$store.dispatch('swipeScaler/reset')
|
||||||
|
}
|
||||||
},
|
},
|
||||||
handleKeyupEvent (e) {
|
handleKeyupEvent (e) {
|
||||||
if (this.showing && e.keyCode === 27) { // escape
|
if (this.showing && e.keyCode === 27) { // escape
|
||||||
|
|
Loading…
Reference in a new issue