From 18628b821ec4ca1c246d81d681fa0c841841cfb6 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 10 Feb 2020 04:04:10 +0900 Subject: [PATCH] Better title adjust logic --- src/client/app.vue | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/client/app.vue b/src/client/app.vue index e7f61f589..22a56eb1f 100644 --- a/src/client/app.vue +++ b/src/client/app.vue @@ -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');