From 7d1cb2e2a31405c30945ba2c04179451ff858b4c Mon Sep 17 00:00:00 2001 From: tamaina Date: Sat, 22 Feb 2020 00:56:36 +0900 Subject: [PATCH] Fix #6057 --- src/client/components/media-list.vue | 37 +++++++++++++++++----------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/client/components/media-list.vue b/src/client/components/media-list.vue index fb8824c5b41d..2c5df4ecaa0d 100644 --- a/src/client/components/media-list.vue +++ b/src/client/components/media-list.vue @@ -40,7 +40,8 @@ export default Vue.extend({ }, data() { return { - gridInnerStyle: {} + gridInnerStyle: {}, + sizeWaiting: false } }, mounted() { @@ -59,20 +60,28 @@ export default Vue.extend({ }, 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; - } + if (this.sizeWaiting) return; - this.gridInnerStyle = { height: `${height}px` }; - } else { - this.gridInnerStyle = {}; - } + this.sizeWaiting = true; + + window.requestAnimationFrame(() => { + this.sizeWaiting = false; + + 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 = {}; + } + }); } } });