From ef0cd2fea3d5ed04964c97e148045df0b5e479ca Mon Sep 17 00:00:00 2001 From: Samuell Date: Wed, 28 Feb 2018 19:12:33 +0100 Subject: [PATCH] fix(MdTabs): remove ResizeObserver to improve the size and position calculation (#1552) --- src/components/MdTabs/MdTabs.vue | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/components/MdTabs/MdTabs.vue b/src/components/MdTabs/MdTabs.vue index f85d0892f..4368ceb35 100644 --- a/src/components/MdTabs/MdTabs.vue +++ b/src/components/MdTabs/MdTabs.vue @@ -207,22 +207,20 @@ } } }, + callResizeFunctions () { + this.setIndicatorStyles() + this.calculateTabPos() + }, setupObservers () { - if ('ResizeObserver' in window) { - this.resizeObserver = new window.ResizeObserver(this.setIndicatorStyles) - this.resizeObserver.observe(this.$el) - } else { - this.resizeObserver = MdObserveElement(this.$el.querySelector('.md-tabs-content'), { - childList: true, - characterData: true, - subtree: true - }, () => { - this.setIndicatorStyles() - this.calculateTabPos() - }) + this.resizeObserver = MdObserveElement(this.$el.querySelector('.md-tabs-content'), { + childList: true, + characterData: true, + subtree: true + }, () => { + this.callResizeFunctions() + }) - window.addEventListener('resize', this.setIndicatorStyles) - } + window.addEventListener('resize', this.callResizeFunctions) }, setupWatchers () { if (this.mdSyncRoute) { @@ -268,7 +266,7 @@ this.resizeObserver.disconnect() } - window.removeEventListener('resize', this.setIndicatorStyles) + window.removeEventListener('resize', this.callResizeFunctions) this.$refs.navigation.removeEventListener('transitionend', this.setIndicatorStyles) } })