2019-01-04 13:10:41 +00:00
|
|
|
<template>
|
2019-01-04 13:55:30 +00:00
|
|
|
<div>
|
2019-01-04 13:10:41 +00:00
|
|
|
<div class="gallery-thumbs__spacer"></div>
|
2019-01-09 17:34:01 +00:00
|
|
|
<ul ref="galleryThumbsList"
|
|
|
|
class="gallery-thumbs__list">
|
2019-01-09 12:56:10 +00:00
|
|
|
<li v-for="(gallery, galleryIndex) in galleries"
|
2019-01-09 14:12:30 +00:00
|
|
|
:key="galleryIndex"
|
|
|
|
:class="{ 'is-active': activeRow === galleryIndex }"
|
|
|
|
class="gallery-thumbs__row-container">
|
2019-01-09 17:34:01 +00:00
|
|
|
<ul ref="galleryThumbsRowContainers"
|
2019-01-09 12:56:10 +00:00
|
|
|
class="gallery-thumbs__row"
|
2019-01-09 17:34:01 +00:00
|
|
|
:style="{ 'transform': 'translate3d(' + thumbRowOffsets[galleryIndex] + 'px, 0, 0)' }">
|
2019-01-09 12:56:10 +00:00
|
|
|
<li class="featured-image-spacer mobile-only"
|
2019-01-04 13:55:30 +00:00
|
|
|
:style="{ 'height': featuredHeight }">
|
2019-01-09 17:34:01 +00:00
|
|
|
<ThumbNav class="thumb-nav thumb-nav--large mobile-only"
|
2019-01-09 12:56:10 +00:00
|
|
|
direction="right"
|
2019-01-09 14:12:30 +00:00
|
|
|
@navClick="handleNavClick(galleryIndex, 'right')" />
|
2019-01-04 13:55:30 +00:00
|
|
|
</li>
|
2019-01-09 12:56:10 +00:00
|
|
|
<li v-for="(image, imageIndex) in gallery.images"
|
|
|
|
:ref="galleryIndex == 0 && imageIndex == 0 ? 'thumbContainer' : null"
|
2019-01-04 13:10:41 +00:00
|
|
|
class="thumb-container"
|
2019-01-10 14:44:28 +00:00
|
|
|
:style="{ 'background-image': 'url(' + image.thumbUrl + ')' }"
|
2019-01-09 21:23:03 +00:00
|
|
|
:key="galleryIndex + '.' + imageIndex + '.' + image.url"
|
|
|
|
@click="$emit('thumbClick', galleryIndex, imageIndex)">
|
2019-01-09 17:34:01 +00:00
|
|
|
<ThumbNav class="thumb-nav thumb-nav--left mobile-only"
|
2019-01-09 12:56:10 +00:00
|
|
|
direction="left"
|
2019-01-09 14:12:30 +00:00
|
|
|
@navClick="handleNavClick(galleryIndex, 'left')" />
|
2019-01-09 12:56:10 +00:00
|
|
|
<ThumbNav v-if="imageIndex < gallery.images.length - 1"
|
2019-01-09 17:34:01 +00:00
|
|
|
class="thumb-nav mobile-only"
|
2019-01-09 12:56:10 +00:00
|
|
|
direction="right"
|
2019-01-09 14:12:30 +00:00
|
|
|
@navClick="handleNavClick(galleryIndex, 'right')" />
|
2019-01-04 13:10:41 +00:00
|
|
|
<span>{{ image.thumbUrl }}</span>
|
2019-01-09 14:12:30 +00:00
|
|
|
<span>{{ galleryIndex }}: {{ imageIndex }}</span>
|
2019-01-04 13:10:41 +00:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</li>
|
2019-01-09 17:34:01 +00:00
|
|
|
<ThumbNav class="thumb-nav thumb-nav--left mobile-hide"
|
2019-01-09 19:55:19 +00:00
|
|
|
:class="{ 'is-active': isLeftDesktopNavActive }"
|
2019-01-09 17:34:01 +00:00
|
|
|
direction="left"
|
|
|
|
@navClick="handleNavClickDesktop(activeRow, 'left')"/>
|
|
|
|
<ThumbNav class="thumb-nav thumb-nav--right mobile-hide"
|
2019-01-09 19:55:19 +00:00
|
|
|
:class="{ 'is-active': thumbRowOffsets[activeRow] != 0 }"
|
2019-01-09 17:34:01 +00:00
|
|
|
direction="right"
|
|
|
|
@navClick="handleNavClickDesktop(activeRow, 'right')"/>
|
2019-01-04 13:10:41 +00:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-01-04 16:18:45 +00:00
|
|
|
import ThumbNav from '@/components/ThumbNav'
|
|
|
|
|
2019-01-04 13:10:41 +00:00
|
|
|
export default {
|
|
|
|
components: {
|
2019-01-04 16:18:45 +00:00
|
|
|
ThumbNav
|
2019-01-04 13:10:41 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
galleries: {
|
|
|
|
type: Array,
|
|
|
|
required: true
|
2019-01-04 13:55:30 +00:00
|
|
|
},
|
|
|
|
featuredHeight: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
2019-01-09 14:12:30 +00:00
|
|
|
},
|
|
|
|
activeRow: {
|
|
|
|
type: Number,
|
|
|
|
required: true
|
2019-01-04 13:10:41 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
data () {
|
|
|
|
return {
|
2019-01-09 12:56:10 +00:00
|
|
|
thumbRowOffsets: new Array(this.galleries.length),
|
2019-01-09 19:55:19 +00:00
|
|
|
isLeftDesktopNavActive: false,
|
|
|
|
resizeIsThrottling: false
|
2019-01-09 14:12:30 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
thumbsVerticalOffset () {
|
|
|
|
let rowHeight = this.$refs.thumbContainer ? this.$refs.thumbContainer[0].clientHeight : 0;
|
|
|
|
return rowHeight * this.activeRow
|
2019-01-04 13:10:41 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2019-01-09 19:55:19 +00:00
|
|
|
watch: {
|
|
|
|
activeRow: function(val) {
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.initLeftNav()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2019-01-04 16:18:45 +00:00
|
|
|
mounted () {
|
2019-01-09 12:56:10 +00:00
|
|
|
this.$nextTick(function () {
|
|
|
|
this.resetOffsets()
|
2019-01-09 19:55:19 +00:00
|
|
|
this.initLeftNav()
|
2019-01-09 12:56:10 +00:00
|
|
|
})
|
2019-01-09 19:55:19 +00:00
|
|
|
window.addEventListener('resize', this.handleResize)
|
2019-01-04 16:18:45 +00:00
|
|
|
},
|
|
|
|
|
2019-01-04 13:10:41 +00:00
|
|
|
methods: {
|
2019-01-09 19:55:19 +00:00
|
|
|
initLeftNav () {
|
2019-01-09 21:23:03 +00:00
|
|
|
if (this.$refs.galleryThumbsRowContainers[this.activeRow] && this.$refs.galleryThumbsList) {
|
|
|
|
let offset = this.thumbRowOffsets[this.activeRow]
|
|
|
|
let totalRowWidth = this.$refs.galleryThumbsRowContainers[this.activeRow].clientWidth
|
|
|
|
let visibleRowWidth = this.$refs.galleryThumbsList.clientWidth
|
|
|
|
let maxOffset = totalRowWidth - visibleRowWidth
|
|
|
|
this.isLeftDesktopNavActive = (totalRowWidth > visibleRowWidth)
|
|
|
|
&& (offset < maxOffset)
|
|
|
|
}
|
2019-01-09 19:55:19 +00:00
|
|
|
},
|
2019-01-09 12:56:10 +00:00
|
|
|
resetOffsets() {
|
|
|
|
for (let index = 0; index < this.thumbRowOffsets.length; index++) {
|
|
|
|
this.$set(this.thumbRowOffsets, index, 0)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
handleNavClick(source, direction) {
|
|
|
|
let offset = this.thumbRowOffsets[source]
|
|
|
|
let thumbContainerWidth = this.$refs.thumbContainer[0].clientWidth
|
|
|
|
if (direction === 'left') {
|
2019-01-09 17:34:01 +00:00
|
|
|
offset += thumbContainerWidth
|
2019-01-09 12:56:10 +00:00
|
|
|
} else if (direction === 'right') {
|
2019-01-09 17:34:01 +00:00
|
|
|
offset -= thumbContainerWidth
|
|
|
|
}
|
|
|
|
offset = offset > 0 ? 0 : offset
|
|
|
|
this.$set(this.thumbRowOffsets, source, offset)
|
|
|
|
},
|
|
|
|
handleNavClickDesktop(source, direction) {
|
|
|
|
let offset = this.thumbRowOffsets[source]
|
|
|
|
let thumbContainerWidth = this.$refs.thumbContainer[0].clientWidth
|
|
|
|
let visibleRowWidth = this.$refs.galleryThumbsList.clientWidth
|
|
|
|
let totalRowWidth = this.$refs.galleryThumbsRowContainers[source].clientWidth
|
|
|
|
let maxOffset = totalRowWidth - visibleRowWidth
|
|
|
|
if (direction === 'left') {
|
2019-01-09 12:56:10 +00:00
|
|
|
offset += thumbContainerWidth
|
2019-01-09 17:34:01 +00:00
|
|
|
} else if (direction === 'right') {
|
|
|
|
offset -= thumbContainerWidth
|
2019-01-09 19:55:19 +00:00
|
|
|
if (offset != 0) {
|
|
|
|
this.isLeftDesktopNavActive = true
|
|
|
|
}
|
2019-01-09 17:34:01 +00:00
|
|
|
}
|
|
|
|
if (offset < 0) {
|
|
|
|
offset = 0
|
2019-01-09 19:55:19 +00:00
|
|
|
} else if (offset >= maxOffset) {
|
2019-01-09 17:34:01 +00:00
|
|
|
offset = maxOffset
|
2019-01-09 19:55:19 +00:00
|
|
|
this.isLeftDesktopNavActive = false
|
2019-01-09 12:56:10 +00:00
|
|
|
}
|
|
|
|
this.$set(this.thumbRowOffsets, source, offset)
|
2019-01-09 19:55:19 +00:00
|
|
|
// this.isLeftDesktopNavActive
|
|
|
|
},
|
|
|
|
handleResize() {
|
|
|
|
if (!this.resizeIsThrottling) {
|
|
|
|
this.resizeIsThrottling = true
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.resetOffsets()
|
|
|
|
this.initLeftNav()
|
|
|
|
this.resizeIsThrottling = false
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-01-04 15:23:13 +00:00
|
|
|
}
|
2019-01-04 13:10:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.gallery-thumbs__row {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
list-style: none;
|
|
|
|
padding: 0;
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
|
2019-01-10 14:44:28 +00:00
|
|
|
.thumb-container {
|
|
|
|
background-size: cover;
|
|
|
|
background-position: center center;
|
|
|
|
}
|
|
|
|
|
2019-01-04 13:10:41 +00:00
|
|
|
@media (max-width: $bp__layout) {
|
2019-01-09 17:34:01 +00:00
|
|
|
.mobile-hide {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
2019-01-04 13:10:41 +00:00
|
|
|
.gallery-thumbs__spacer {
|
|
|
|
display:none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.gallery-thumbs__row {
|
|
|
|
position: relative;
|
2019-01-09 12:56:10 +00:00
|
|
|
transition : transform .5s;
|
2019-01-04 13:10:41 +00:00
|
|
|
}
|
|
|
|
|
2019-01-09 12:56:10 +00:00
|
|
|
.featured-image-spacer {
|
|
|
|
position: relative;
|
|
|
|
height: calc(50vh - #{$site-menu__header-height / 2}) !important; // must override inline style set with prop
|
2019-01-04 13:10:41 +00:00
|
|
|
width: 100vw;
|
|
|
|
flex: 0 0 100vw;
|
|
|
|
}
|
|
|
|
|
|
|
|
.thumb-container {
|
2019-01-09 12:56:10 +00:00
|
|
|
position: relative;
|
|
|
|
height: calc(50vh - #{$site-menu__header-height / 2});
|
2019-01-04 16:18:45 +00:00
|
|
|
width: 100vw;
|
2019-01-10 14:44:28 +00:00
|
|
|
|
|
|
|
background-size: cover;
|
|
|
|
background-position: center center;
|
2019-01-04 13:10:41 +00:00
|
|
|
}
|
2019-01-09 12:56:10 +00:00
|
|
|
|
|
|
|
.thumb-nav {
|
|
|
|
position: absolute;
|
|
|
|
width: 8rem;
|
|
|
|
height: 8rem;
|
|
|
|
bottom: 1rem;
|
|
|
|
right: 1rem;
|
|
|
|
|
|
|
|
&--left {
|
|
|
|
left: 1rem;
|
|
|
|
right: auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
&--large {
|
|
|
|
width: 12rem;
|
|
|
|
height: 12rem;
|
|
|
|
}
|
|
|
|
}
|
2019-01-04 13:10:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@media (min-width: $bp__layout) {
|
|
|
|
$thumbs-height: 8rem;
|
|
|
|
|
|
|
|
.mobile-only {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
2019-01-09 17:34:01 +00:00
|
|
|
.mobile-hide {
|
|
|
|
display: initial;
|
|
|
|
}
|
|
|
|
|
2019-01-09 12:56:10 +00:00
|
|
|
.featured-image-spacer {
|
2019-01-04 13:10:41 +00:00
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.thumb-container {
|
|
|
|
height: $thumbs-height;
|
|
|
|
}
|
|
|
|
|
2019-01-09 14:12:30 +00:00
|
|
|
.gallery__thumbs {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
2019-01-04 13:55:30 +00:00
|
|
|
.gallery-thumbs__list {
|
2019-01-09 17:34:01 +00:00
|
|
|
position: relative;
|
2019-01-04 13:55:30 +00:00
|
|
|
height: $thumbs-height;
|
2019-01-09 14:12:30 +00:00
|
|
|
flex: 0 0 $thumbs-height;
|
2019-01-04 13:55:30 +00:00
|
|
|
|
2019-01-04 13:10:41 +00:00
|
|
|
overflow: hidden;
|
2019-01-10 17:17:15 +00:00
|
|
|
|
|
|
|
transition: opacity .3s; // TEMP
|
|
|
|
opacity: .3;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
2019-01-04 13:10:41 +00:00
|
|
|
}
|
|
|
|
|
2019-01-09 14:12:30 +00:00
|
|
|
.gallery-thumbs__row-container {
|
2019-01-09 17:34:01 +00:00
|
|
|
position: absolute;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
2019-01-09 14:12:30 +00:00
|
|
|
|
|
|
|
transition: opacity .5s;
|
|
|
|
opacity: 0;
|
2019-01-09 21:23:03 +00:00
|
|
|
pointer-events: none;
|
2019-01-09 14:12:30 +00:00
|
|
|
|
|
|
|
&.is-active {
|
|
|
|
transition: opacity .5s .3s;
|
|
|
|
opacity: 1;
|
2019-01-09 21:23:03 +00:00
|
|
|
pointer-events: auto;
|
2019-01-09 14:12:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-04 13:55:30 +00:00
|
|
|
.gallery-thumbs__row {
|
2019-01-09 14:12:30 +00:00
|
|
|
position: absolute;
|
|
|
|
height: 100%;
|
|
|
|
top: 0;
|
2019-01-09 17:34:01 +00:00
|
|
|
right: 0;
|
|
|
|
|
|
|
|
transition: transform .5s;
|
2019-01-04 13:55:30 +00:00
|
|
|
}
|
2019-01-04 16:18:45 +00:00
|
|
|
|
|
|
|
.thumb-nav {
|
2019-01-09 17:34:01 +00:00
|
|
|
position: absolute;
|
|
|
|
top: 1rem;
|
|
|
|
width: $thumbs-height - 2rem;
|
|
|
|
height: $thumbs-height - 2rem;
|
|
|
|
|
|
|
|
transition: opacity .5s;
|
|
|
|
opacity: 0;
|
|
|
|
pointer-events: none;
|
|
|
|
|
|
|
|
&.is-active {
|
|
|
|
opacity: 1;
|
|
|
|
pointer-events: auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
&--left {
|
|
|
|
left: 1rem,;
|
|
|
|
}
|
|
|
|
|
|
|
|
&--right {
|
|
|
|
right: 1rem,;
|
|
|
|
}
|
|
|
|
|
|
|
|
background-color: rgba(red, .3);
|
2019-01-04 16:18:45 +00:00
|
|
|
}
|
2019-01-04 13:10:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|