From 0853639993b1b2d4fe0d23f572578194f14d5242 Mon Sep 17 00:00:00 2001 From: ManjaroOne666 Date: Tue, 29 Jan 2019 12:40:35 +0000 Subject: [PATCH] fix: imageviewer sometimes not updating correctly the first time history back is executed after page refresh --- components/GalleryPage.vue | 22 ++++++++++++---------- components/GalleryThumbs.vue | 4 ---- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/components/GalleryPage.vue b/components/GalleryPage.vue index 333d626..90b7296 100644 --- a/components/GalleryPage.vue +++ b/components/GalleryPage.vue @@ -74,17 +74,19 @@ export default { $route () { const query = this.$route.query if (!query || !query.gallery) { return } - const gallery = parseInt(query.gallery) - const image = parseInt(query.image) || 0 + this.$nextTick(() => { + const gallery = parseInt(query.gallery) + const image = parseInt(query.image) || 0 - if (gallery !== this.activeGalleryIndex) { - this.activeRow = gallery - this.activeGalleryIndex = gallery - } - if (image !== this.activeImageIndex) { - this.activeImageIndex = image - this.showImage = image - } + if (gallery !== this.activeGalleryIndex) { + this.activeRow = gallery + this.activeGalleryIndex = gallery + } + if (image !== this.activeImageIndex) { + this.activeImageIndex = image + this.showImage = image + } + }) } }, diff --git a/components/GalleryThumbs.vue b/components/GalleryThumbs.vue index 9cdba2e..4fc2a03 100644 --- a/components/GalleryThumbs.vue +++ b/components/GalleryThumbs.vue @@ -131,9 +131,7 @@ export default { methods: { // TOOD move logic of getting sizes of elements into getter methods scrollToThumb (thumbIndex) { - console.log('scrollToThumb') if (thumbIndex >= this.galleries[this.activeRow].images.length || thumbIndex < 0) { return } - console.log('scrollToThumb: executing') const containerWidth = this.$refs.galleryThumbsList.clientWidth const thumbWidth = this.$refs.thumbContainer[0].clientWidth let offset = this.thumbRowOffsets[this.activeRow] @@ -142,11 +140,9 @@ export default { if (containerWidth < thumbPosition - offset) { this.$set(this.thumbRowOffsets, this.activeRow, thumbPosition - containerWidth + 1) - // console.log(`(${containerWidth + offset}) ${containerWidth} + ${offset} > ${rowWidth}`) this.isLeftDesktopNavActive = containerWidth + offset > rowWidth } else if (thumbPosition <= offset) { this.$set(this.thumbRowOffsets, this.activeRow, thumbPosition - thumbWidth) - // console.log(`(${containerWidth + offset}) ${containerWidth} + ${offset} > ${rowWidth}`) this.isLeftDesktopNavActive = containerWidth + offset > rowWidth }