Reset position on swipe end even if we cannot navigate

This commit is contained in:
Tusooa Zhu 2021-08-02 20:03:01 -04:00
parent e2f3929872
commit 9d4dd64276
No known key found for this signature in database
GPG key ID: 7B467EDE43A08224

View file

@ -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()