logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git
commit: 544db06294e3bb1948aec97d870d7506bf34252f
parent d9030b4fddc9f47cb2f16a7a65f57a5703059e3f
Author: Tusooa Zhu <tusooa@kazv.moe>
Date:   Sun,  1 Aug 2021 23:42:34 -0400

Add pan threshold

Diffstat:

Msrc/components/media_modal/media_modal.js18+++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/components/media_modal/media_modal.js b/src/components/media_modal/media_modal.js @@ -19,6 +19,8 @@ library.add( ) const onlyXAxis = ([x, y]) => [x, 0] +const SCALING_RESET_MIN = 1.1 +const SCALING_ENABLE_MOVE_THRESHOLD = 1 const MediaModal = { components: { @@ -116,11 +118,17 @@ const MediaModal = { this.loading = false }, 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) { + if (this.scaling > SCALING_ENABLE_MOVE_THRESHOLD) { + this.$store.dispatch('swipeScaler/finish') + return + } if (sign === 0) { - this.$store.dispatch('swipeScaler/revert') + this.$store.dispatch('swipeScaler/reset') } else if (sign > 0) { this.goNext() } else { @@ -132,7 +140,11 @@ const MediaModal = { this.$store.dispatch('swipeScaler/apply', { offsets, scaling }) }, 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) { if (this.showing && e.keyCode === 27) { // escape