current image shows in image viewer

This commit is contained in:
ManjaroOne666 2019-01-09 21:23:03 +00:00
parent d2f0af9e98
commit 0c74042fad
4 changed files with 54 additions and 11 deletions

View File

@ -1,6 +1,7 @@
<template> <template>
<div class="image-viewer" <div class="image-viewer"
:class="{ 'is-visible': isVisible }"> :class="{ 'is-visible': isVisible }"
:style="imageViewerStyle">
<div class="close-viewer" <div class="close-viewer"
@click="$emit('close')"> @click="$emit('close')">
X X
@ -14,6 +15,13 @@ export default {
isVisible: { isVisible: {
type: Boolean, type: Boolean,
required: true required: true
},
imageUrl: {
type: String,
required: false,
default () {
return ''
}
} }
}, },
@ -22,6 +30,14 @@ export default {
} }
}, },
computed: {
imageViewerStyle () {
return {
backgroundImage: 'url(' + this.imageUrl + ')'
}
}
},
methods: { methods: {
} }
} }
@ -34,6 +50,8 @@ export default {
magenta, magenta,
cyan cyan
); // TEMP ); // TEMP
background-size: cover;
background-position: center center;
} }
@media (max-width: $bp__layout) { @media (max-width: $bp__layout) {
@ -55,4 +73,10 @@ export default {
} }
} }
} }
@media (min-width: $bp__layout) {
.close-viewer {
display: none;
}
}
</style> </style>

View File

@ -2,6 +2,7 @@
<div class="gallery-page"> <div class="gallery-page">
<GalleryImageViewer class="image-viewer" <GalleryImageViewer class="image-viewer"
:is-visible="imageViewerIsVisible" :is-visible="imageViewerIsVisible"
:image-url="viewingImageUrl"
@close="imageViewerIsVisible = false" /> @close="imageViewerIsVisible = false" />
<div class="gallery"> <div class="gallery">
<GalleryFeatured class="gallery__featured" <GalleryFeatured class="gallery__featured"
@ -11,7 +12,8 @@
<GalleryThumbs class="gallery__thumbs" <GalleryThumbs class="gallery__thumbs"
:featured-height="featuredImageHeight" :featured-height="featuredImageHeight"
:galleries="galleries" :galleries="galleries"
:active-row="activeRow" /> :active-row="activeRow"
@thumbClick="handleThumbClick"/>
</div> </div>
</div> </div>
</template> </template>
@ -39,13 +41,25 @@ export default {
return { return {
featuredImageHeight: '16rem', featuredImageHeight: '16rem',
imageViewerIsVisible: false, imageViewerIsVisible: false,
activeRow: 0 activeRow: 0,
activeGalleryIndex: 0,
activeImageIndex: 0
}
},
computed: {
viewingImageUrl () {
return this.galleries[this.activeGalleryIndex].images[this.activeImageIndex].url
} }
}, },
methods: { methods: {
handleFeaturedClick (index) { handleFeaturedClick (index) {
this.activeRow = index this.activeRow = index
},
handleThumbClick(gallery, image) {
this.activeGalleryIndex = gallery
this.activeImageIndex = image
} }
} }
} }

View File

@ -19,7 +19,8 @@
<li v-for="(image, imageIndex) in gallery.images" <li v-for="(image, imageIndex) in gallery.images"
:ref="galleryIndex == 0 && imageIndex == 0 ? 'thumbContainer' : null" :ref="galleryIndex == 0 && imageIndex == 0 ? 'thumbContainer' : null"
class="thumb-container" class="thumb-container"
:key="galleryIndex + '.' + imageIndex + '.' + image.url"> :key="galleryIndex + '.' + imageIndex + '.' + image.url"
@click="$emit('thumbClick', galleryIndex, imageIndex)">
<ThumbNav class="thumb-nav thumb-nav--left mobile-only" <ThumbNav class="thumb-nav thumb-nav--left mobile-only"
direction="left" direction="left"
@navClick="handleNavClick(galleryIndex, 'left')" /> @navClick="handleNavClick(galleryIndex, 'left')" />
@ -100,12 +101,14 @@ export default {
methods: { methods: {
initLeftNav () { initLeftNav () {
if (this.$refs.galleryThumbsRowContainers[this.activeRow] && this.$refs.galleryThumbsList) {
let offset = this.thumbRowOffsets[this.activeRow] let offset = this.thumbRowOffsets[this.activeRow]
let totalRowWidth = this.$refs.galleryThumbsRowContainers[this.activeRow].clientWidth let totalRowWidth = this.$refs.galleryThumbsRowContainers[this.activeRow].clientWidth
let visibleRowWidth = this.$refs.galleryThumbsList.clientWidth let visibleRowWidth = this.$refs.galleryThumbsList.clientWidth
let maxOffset = totalRowWidth - visibleRowWidth let maxOffset = totalRowWidth - visibleRowWidth
this.isLeftDesktopNavActive = (totalRowWidth > visibleRowWidth) this.isLeftDesktopNavActive = (totalRowWidth > visibleRowWidth)
&& (offset < maxOffset) && (offset < maxOffset)
}
}, },
resetOffsets() { resetOffsets() {
for (let index = 0; index < this.thumbRowOffsets.length; index++) { for (let index = 0; index < this.thumbRowOffsets.length; index++) {
@ -254,10 +257,12 @@ export default {
transition: opacity .5s; transition: opacity .5s;
opacity: 0; opacity: 0;
pointer-events: none;
&.is-active { &.is-active {
transition: opacity .5s .3s; transition: opacity .5s .3s;
opacity: 1; opacity: 1;
pointer-events: auto;
} }
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<div @click="$emit('navClick')">ThumbNav--{{ direction }}</div> <div @click.stop="$emit('navClick')">ThumbNav--{{ direction }}</div>
</template> </template>
<script> <script>