From 9d4dd64276072381eb5ddd2eccc48dddb21d6195 Mon Sep 17 00:00:00 2001 From: Tusooa Zhu Date: Mon, 2 Aug 2021 20:03:01 -0400 Subject: [PATCH] Reset position on swipe end even if we cannot navigate --- src/components/media_modal/media_modal.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/components/media_modal/media_modal.js b/src/components/media_modal/media_modal.js index 0bc8a658..ffc7c365 100644 --- a/src/components/media_modal/media_modal.js +++ b/src/components/media_modal/media_modal.js @@ -65,14 +65,12 @@ const MediaModal = { if (this.canNavigate) { const prevIndex = this.currentIndex === 0 ? this.media.length - 1 : (this.currentIndex - 1) this.$store.dispatch('setCurrent', this.media[prevIndex]) - this.$refs.pinchZoom.setTransform({ scale: 1, x: 0, y: 0 }) } }, goNext () { if (this.canNavigate) { const nextIndex = this.currentIndex === this.media.length - 1 ? 0 : (this.currentIndex + 1) this.$store.dispatch('setCurrent', this.media[nextIndex]) - this.$refs.pinchZoom.setTransform({ scale: 1, x: 0, y: 0 }) } }, handleSwipePreview (offsets) { @@ -80,9 +78,8 @@ const MediaModal = { }, handleSwipeEnd (sign) { console.log('handleSwipeEnd:', sign) - if (sign === 0) { - this.$refs.pinchZoom.setTransform({ scale: 1, x: 0, y: 0 }) - } else if (sign > 0) { + this.$refs.pinchZoom.setTransform({ scale: 1, x: 0, y: 0 }) + if (sign > 0) { this.goNext() } else { this.goPrev()