diff options
author | Julius Härtl <jus@bitgrid.net> | 2020-01-02 14:39:50 +0300 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2020-01-02 14:39:50 +0300 |
commit | 174061ebe71aca521da722f745bc3db28b543a13 (patch) | |
tree | 489257ba4252b07f22b67b067187759d913eec7d /src | |
parent | 5475818b842b93107115028b90a42b65f07595e5 (diff) |
Wait with menubar redraw until width is available
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/components/MenuBar.vue | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/components/MenuBar.vue b/src/components/MenuBar.vue index 365b656d5..a1d3b64c4 100644 --- a/src/components/MenuBar.vue +++ b/src/components/MenuBar.vue @@ -185,16 +185,22 @@ export default { iconCount() { this.forceRecompute // eslint-disable-line this.windowWidth // eslint-disable-line - const menuBarWidth = this.$refs.menubar && this.$refs.menubar.clientWidth > 100 ? this.$refs.menubar.clientWidth : this.windowWidth - 200 + const menuBarWidth = this.$refs.menubar && this.$refs.menubar.clientWidth > 100 ? this.$refs.menubar.clientWidth : 100 const iconCount = Math.max((Math.floor(menuBarWidth / 44) - 2), 0) return iconCount }, }, - beforeMount() { - this.redrawMenuBar() - }, mounted() { window.addEventListener('resize', this.getWindowWidth) + this.checkInterval = setInterval(() => { + const isWidthAvailable = (this.$refs.menubar && this.$refs.menubar.clientWidth > 0) + if (this.isRichEditor && isWidthAvailable) { + this.redrawMenuBar() + } + if (!this.isRichEditor || isWidthAvailable) { + clearInterval(this.checkInterval) + } + }, 100) }, beforeDestroy() { window.removeEventListener('resize', this.getWindowWidth) |