Better title adjust logic

This commit is contained in:
syuilo 2020-02-10 04:04:10 +09:00
parent 14925f8727
commit a45b9c9e31

View File

@ -257,11 +257,6 @@ export default Vue.extend({
}
});
setInterval(() => {
if (this.showNav) return; // TODO: false
this.$refs.title.style.left = (this.$refs.main.getBoundingClientRect().left - this.$refs.nav.offsetWidth) + 'px';
}, 1000);
// https://stackoverflow.com/questions/33891709/when-flexbox-items-wrap-in-column-mode-container-does-not-grow-its-width
if (this.enableWidgets) {
setInterval(() => {
@ -273,6 +268,16 @@ export default Vue.extend({
}
},
mounted() {
const adjustTitlePosition = () => {
this.$refs.title.style.left = (this.$refs.main.getBoundingClientRect().left - this.$refs.nav.offsetWidth) + 'px';
};
adjustTitlePosition();
window.addEventListener('resize', adjustTitlePosition);
},
methods: {
help() {
this.$router.push('/docs/keyboard-shortcut');