Skip to content

Commit 28c7e52

Browse files
committed
watch for dom changes on tab parent #248
1 parent 39cd6f3 commit 28c7e52

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

src/components/mdTabs/mdTabs.vue

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="md-tabs" :class="[themeClass, tabClasses]">
3-
<md-whiteframe md-tag="nav" class="md-tabs-navigation" :md-elevation="mdElevation" :class="navigationClasses" ref="tabNavigation">
3+
<md-whiteframe md-tag="nav" class="md-tabs-navigation" :md-elevation="mdElevation" :class="navigationClasses">
44
<button
55
v-for="header in tabList"
66
:key="header.id"
@@ -121,17 +121,11 @@
121121
},
122122
observeElementChanges() {
123123
this.contentObserver = new MutationObserver(this.calculateOnWatch);
124-
this.navigationObserver = new MutationObserver(this.calculateOnWatch);
125-
this.contentObserver.observe(this.$refs.tabContent, {
124+
this.contentObserver.observe(this.$parent.$el, {
126125
childList: true,
127126
attributes: true,
128127
characterData: true,
129-
subtree: true,
130-
attributeOldValue: true,
131-
characterDataOldValue: true
132-
});
133-
this.navigationObserver.observe(this.$refs.tabNavigation.$el, {
134-
attributes: true
128+
subtree: true
135129
});
136130
},
137131
getTabIndex(id) {
@@ -152,11 +146,10 @@
152146
},
153147
calculateTabsWidthAndPosition() {
154148
const width = this.$el.offsetWidth;
149+
let index = 0;
155150
156151
this.contentWidth = width * this.activeTabNumber + 'px';
157152
158-
let index = 0;
159-
160153
for (const tabId in this.tabList) {
161154
let tab = this.tabList[tabId];
162155
@@ -219,10 +212,6 @@
219212
this.contentObserver.disconnect();
220213
}
221214
222-
if (this.navigationObserver) {
223-
this.navigationObserver.disconnect();
224-
}
225-
226215
window.removeEventListener('resize', this.calculateOnWatch);
227216
}
228217
};

0 commit comments

Comments
 (0)