172 lines
3.8 KiB
Vue
172 lines
3.8 KiB
Vue
<template>
|
|
<div>
|
|
<div class="gallery-thumbs__spacer"></div>
|
|
<ul class="gallery-thumbs__list">
|
|
<li v-for="(gallery, galleryIndex) in galleries"
|
|
:key="galleryIndex">
|
|
<ul :ref="'thumbs-row-' + galleryIndex"
|
|
class="gallery-thumbs__row"
|
|
:style="{ 'transform': 'translate3d(-' + thumbRowOffsets[galleryIndex] + 'px, 0, 0)' }">
|
|
<li class="featured-image-spacer mobile-only"
|
|
:style="{ 'height': featuredHeight }">
|
|
<ThumbNav class="thumb-nav thumb-nav--large"
|
|
direction="right"
|
|
@clicked="handleNavClick(galleryIndex, 'right')" />
|
|
</li>
|
|
<li v-for="(image, imageIndex) in gallery.images"
|
|
:ref="galleryIndex == 0 && imageIndex == 0 ? 'thumbContainer' : null"
|
|
class="thumb-container"
|
|
:key="galleryIndex + '.' + imageIndex + '.' + image.url">
|
|
<ThumbNav class="thumb-nav thumb-nav--left"
|
|
direction="left"
|
|
@clicked="handleNavClick(galleryIndex, 'left')" />
|
|
<ThumbNav v-if="imageIndex < gallery.images.length - 1"
|
|
class="thumb-nav"
|
|
direction="right"
|
|
@clicked="handleNavClick(galleryIndex, 'right')" />
|
|
<span>{{ image.thumbUrl }}</span>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import ThumbNav from '@/components/ThumbNav'
|
|
|
|
export default {
|
|
components: {
|
|
ThumbNav
|
|
},
|
|
|
|
props: {
|
|
galleries: {
|
|
type: Array,
|
|
required: true
|
|
},
|
|
featuredHeight: {
|
|
type: String,
|
|
required: true
|
|
}
|
|
},
|
|
|
|
data () {
|
|
return {
|
|
thumbRowOffsets: new Array(this.galleries.length),
|
|
// thumbContainerWidth: 0
|
|
}
|
|
},
|
|
|
|
mounted () {
|
|
this.$nextTick(function () {
|
|
this.resetOffsets()
|
|
window.addEventListener('resize', this.resetOffsets)
|
|
})
|
|
},
|
|
|
|
methods: {
|
|
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') {
|
|
offset -= thumbContainerWidth
|
|
} else if (direction === 'right') {
|
|
offset += thumbContainerWidth
|
|
}
|
|
offset = offset < 0 ? 0 : offset
|
|
console.log('offset: ', offset)
|
|
this.$set(this.thumbRowOffsets, source, offset)
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.gallery-thumbs__row {
|
|
display: flex;
|
|
flex-direction: row;
|
|
list-style: none;
|
|
padding: 0;
|
|
margin: 0;
|
|
}
|
|
|
|
@media (max-width: $bp__layout) {
|
|
.gallery-thumbs__spacer {
|
|
display:none;
|
|
}
|
|
|
|
.gallery-thumbs__row {
|
|
position: relative;
|
|
transition : transform .5s;
|
|
}
|
|
|
|
.featured-image-spacer {
|
|
position: relative;
|
|
height: calc(50vh - #{$site-menu__header-height / 2}) !important; // must override inline style set with prop
|
|
width: 100vw;
|
|
flex: 0 0 100vw;
|
|
}
|
|
|
|
.thumb-container {
|
|
position: relative;
|
|
height: calc(50vh - #{$site-menu__header-height / 2});
|
|
width: 100vw;
|
|
}
|
|
|
|
.thumb-nav {
|
|
position: absolute;
|
|
width: 8rem;
|
|
height: 8rem;
|
|
bottom: 1rem;
|
|
right: 1rem;
|
|
|
|
&--left {
|
|
left: 1rem;
|
|
right: auto;
|
|
}
|
|
|
|
&--large {
|
|
width: 12rem;
|
|
height: 12rem;
|
|
}
|
|
}
|
|
}
|
|
|
|
@media (min-width: $bp__layout) {
|
|
$thumbs-height: 8rem;
|
|
|
|
.mobile-only {
|
|
display: none;
|
|
}
|
|
|
|
.featured-image-spacer {
|
|
width: 100%;
|
|
}
|
|
|
|
.thumb-container {
|
|
height: $thumbs-height;
|
|
}
|
|
|
|
.gallery-thumbs__list {
|
|
height: $thumbs-height;
|
|
|
|
overflow: hidden;
|
|
}
|
|
|
|
.gallery-thumbs__row {
|
|
flex: 0 0 $thumbs-height;
|
|
}
|
|
|
|
.thumb-nav {
|
|
display: none;
|
|
}
|
|
}
|
|
|
|
</style>
|