Skip to content

Commit ef0cd2f

Browse files
Samuell1marcosmoura
authored andcommitted
fix(MdTabs): remove ResizeObserver to improve the size and position calculation (#1552)
1 parent 05821e2 commit ef0cd2f

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

src/components/MdTabs/MdTabs.vue

+13-15
Original file line numberDiff line numberDiff line change
@@ -207,22 +207,20 @@
207207
}
208208
}
209209
},
210+
callResizeFunctions () {
211+
this.setIndicatorStyles()
212+
this.calculateTabPos()
213+
},
210214
setupObservers () {
211-
if ('ResizeObserver' in window) {
212-
this.resizeObserver = new window.ResizeObserver(this.setIndicatorStyles)
213-
this.resizeObserver.observe(this.$el)
214-
} else {
215-
this.resizeObserver = MdObserveElement(this.$el.querySelector('.md-tabs-content'), {
216-
childList: true,
217-
characterData: true,
218-
subtree: true
219-
}, () => {
220-
this.setIndicatorStyles()
221-
this.calculateTabPos()
222-
})
215+
this.resizeObserver = MdObserveElement(this.$el.querySelector('.md-tabs-content'), {
216+
childList: true,
217+
characterData: true,
218+
subtree: true
219+
}, () => {
220+
this.callResizeFunctions()
221+
})
223222
224-
window.addEventListener('resize', this.setIndicatorStyles)
225-
}
223+
window.addEventListener('resize', this.callResizeFunctions)
226224
},
227225
setupWatchers () {
228226
if (this.mdSyncRoute) {
@@ -268,7 +266,7 @@
268266
this.resizeObserver.disconnect()
269267
}
270268
271-
window.removeEventListener('resize', this.setIndicatorStyles)
269+
window.removeEventListener('resize', this.callResizeFunctions)
272270
this.$refs.navigation.removeEventListener('transitionend', this.setIndicatorStyles)
273271
}
274272
})

0 commit comments

Comments
 (0)