Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

media-listのgridの高さの調節がうまくいっていないのを修正 #6061

Merged
merged 1 commit into from
Feb 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions src/client/components/media-list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export default Vue.extend({
},
data() {
return {
gridInnerStyle: {}
gridInnerStyle: {},
sizeWaiting: false
}
},
mounted() {
Expand All @@ -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 = {};
}
});
}
}
});
Expand Down