forked from FoundKeyGang/FoundKey
media-listのgridの高さがsub-note-detailsのdetailsの中だと287pxになってしまっていたのを修正 (#5951)
* fix files grid height * missing colon * ✌️ * ✌️ * fix * remove unused event listener
This commit is contained in:
commit
f456feb3ff
1 changed files with 33 additions and 8 deletions
|
@ -3,8 +3,8 @@
|
||||||
<template v-for="media in mediaList.filter(media => !previewable(media))">
|
<template v-for="media in mediaList.filter(media => !previewable(media))">
|
||||||
<x-banner :media="media" :key="media.id"/>
|
<x-banner :media="media" :key="media.id"/>
|
||||||
</template>
|
</template>
|
||||||
<div v-if="mediaList.filter(media => previewable(media)).length > 0" class="gird-container">
|
<div v-if="mediaList.filter(media => previewable(media)).length > 0" class="gird-container" ref="gridOuter">
|
||||||
<div :data-count="mediaList.filter(media => previewable(media)).length" ref="grid">
|
<div :data-count="mediaList.filter(media => previewable(media)).length" :style="gridInnerStyle">
|
||||||
<template v-for="media in mediaList">
|
<template v-for="media in mediaList">
|
||||||
<x-video :video="media" :key="media.id" v-if="media.type.startsWith('video')"/>
|
<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"/>
|
<x-image :image="media" :key="media.id" v-else-if="media.type.startsWith('image')" :raw="raw"/>
|
||||||
|
@ -32,19 +32,44 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
raw: {
|
raw: {
|
||||||
default: false
|
default: false
|
||||||
|
},
|
||||||
|
// specify the parent element
|
||||||
|
parentElement: {
|
||||||
|
type: Object
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
gridInnerStyle: {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
//#region for Safari bug
|
this.size();
|
||||||
if (this.$refs.grid) {
|
window.addEventListener('resize', this.size);
|
||||||
this.$refs.grid.style.height = this.$refs.grid.clientHeight ? `${this.$refs.grid.clientHeight}px`
|
},
|
||||||
: '287px';
|
beforeDestroy() {
|
||||||
}
|
window.removeEventListener('resize', this.size);
|
||||||
//#endregion
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
previewable(file) {
|
previewable(file) {
|
||||||
return file.type.startsWith('video') || file.type.startsWith('image');
|
return file.type.startsWith('video') || file.type.startsWith('image');
|
||||||
|
},
|
||||||
|
size() {
|
||||||
|
// for Safari bug
|
||||||
|
if (this.$refs.gridOuter) {
|
||||||
|
let height = 287;
|
||||||
|
const parent = this.$props.parentElement || this.$parent.$el;
|
||||||
|
|
||||||
|
if (this.$refs.gridOuter.clientHeight) {
|
||||||
|
height = this.$refs.gridOuter.clientHeight;
|
||||||
|
} else if (parent) {
|
||||||
|
height = parent.getBoundingClientRect().width * 9 / 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.gridInnerStyle = { height: `${height}px` };
|
||||||
|
} else {
|
||||||
|
this.gridInnerStyle = {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue