Skip to content
Snippets Groups Projects
Commit a4f197f6 authored by tamaina's avatar tamaina
Browse files

fix files grid height

parent ec222378
No related branches found
No related tags found
No related merge requests found
......@@ -3,8 +3,8 @@
<template v-for="media in mediaList.filter(media => !previewable(media))">
<x-banner :media="media" :key="media.id"/>
</template>
<div v-if="mediaList.filter(media => previewable(media)).length > 0" class="gird-container">
<div :data-count="mediaList.filter(media => previewable(media)).length" ref="grid">
<div v-if="mediaList.filter(media => previewable(media)).length > 0" class="gird-container" ref="gridOuter">
<div :data-count="mediaList.filter(media => previewable(media)).length" :style="gridHeight !== null ? { height: `${gridHeight}px` } : {}">
<template v-for="media in mediaList">
<x-video :video="media" :key="media.id" v-if="media.type.startsWith('video')"/>
<x-image :image="media" :key="media.id" v-else-if="media.type.startsWith('image')" :raw="raw"/>
......@@ -32,16 +32,39 @@ export default Vue.extend({
},
raw: {
default: false
},
width: {
type: Number
}
},
computed: {
gridHeight() {
if (this.$refs.gridOuter) {
if (this.$props.width) {
return this.$props.width * 9 / 16;
} else if (this.$refs.gridOuter.clientHeight) {
return this.$refs.gridOuter.clientHeight;
}
return 287;
}
return null;
}
},
mounted() {
/*mounted() {
console.log(this.$props.width)
//#region for Safari bug
if (this.$refs.grid) {
this.$refs.grid.style.height = this.$refs.grid.clientHeight ? `${this.$refs.grid.clientHeight}px`
: '287px';
if (this.$refs.gridOuter) {
if (this.$props.width) {
this.$refs.gridInner.style.height = `${this.$props.width * 9 / 16}px`
} else if (this.$refs.gridOuter.clientHeight) {
this.$refs.gridInner.style.height = `${this.$refs.gridOuter.clientHeight}px`
} else {
this.$refs.gridInner.style.height = '287px';
}
}
//#endregion
},
},*/
methods: {
previewable(file) {
return file.type.startsWith('video') || file.type.startsWith('image');
......
<template>
<div class="wrmlmaau">
<div class="wrmlmaau" ref="i">
<div class="body">
<span v-if="note.isHidden" style="opacity: 0.5">({{ $t('private') }})</span>
<span v-if="note.deletedAt" style="opacity: 0.5">({{ $t('deleted') }})</span>
......@@ -9,7 +9,7 @@
</div>
<details v-if="note.files.length > 0">
<summary>({{ $t('withNFiles', { n: note.files.length }) }})</summary>
<x-media-list :media-list="note.files"/>
<x-media-list :media-list="note.files" :width="width"/>
</details>
<details v-if="note.poll">
<summary>{{ $t('poll') }}</summary>
......@@ -39,8 +39,13 @@ export default Vue.extend({
},
data() {
return {
width: 0,
faReply
};
},
mounted() {
this.width = this.$refs.i.getBoundingClientRect().width
}
});
</script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment