Use static height if gallery has single image

This commit is contained in:
Edijs 2019-02-14 09:52:23 -07:00
parent 295becd6c8
commit 50f0d21686
2 changed files with 9 additions and 2 deletions

View File

@ -34,7 +34,9 @@ const Gallery = {
return rows return rows
}, },
rowHeight () { rowHeight () {
return itemsPerRow => ({ 'height': `${(this.width / (itemsPerRow + 0.6))}px` }) return itemsPerRow => ({
'height': this.attachments.length === 1 ? '260px' : `${(this.width / (itemsPerRow + 0.6))}px`
})
}, },
useContainFit () { useContainFit () {
return this.$store.state.config.useContainFit return this.$store.state.config.useContainFit

View File

@ -1,6 +1,11 @@
<template> <template>
<div ref="galleryContainer" style="width: 100%;"> <div ref="galleryContainer" style="width: 100%;">
<div class="gallery-row" v-for="row in rows" :style="rowHeight(row.length)" :class="{ 'contain-fit': useContainFit, 'cover-fit': !useContainFit }"> <div
v-for="(row, row_num) in rows"
:key="row_num"
:style="rowHeight(row.length)"
:class="{ 'gallery-row': true, 'contain-fit': useContainFit, 'cover-fit': !useContainFit }"
>
<attachment <attachment
v-for="attachment in row" v-for="attachment in row"
:setMedia="setMedia" :setMedia="setMedia"