Skip to content

Commit

Permalink
fix issue iview#1846
Browse files Browse the repository at this point in the history
  • Loading branch information
cheng-kang committed Oct 29, 2017
1 parent 7a9f6b2 commit 7988575
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/components/tabs/tabs.vue
Expand Up @@ -310,6 +310,16 @@
},
handleResize(){
this.updateNavScroll();
},
isInsideHiddenElement () {
let parentNode = this.$el.parentNode;
while(parentNode) {
if (parentNode.style.display === 'none') {
return parentNode;
}
parentNode = parentNode.parentNode;
}
return false;
}
},
watch: {
Expand All @@ -329,6 +339,18 @@
this.showSlot = this.$slots.extra !== undefined;
this.observer = elementResizeDetectorMaker();
this.observer.listenTo(this.$refs.navWrap, this.handleResize);
const hiddenParentNode = this.isInsideHiddenElement();
if (hiddenParentNode) {
const mutationObserver = new MutationObserver(() => {
if (hiddenParentNode.style.display !== 'none') {
this.updateBar();
mutationObserver.disconnect();
}
});
mutationObserver.observe(hiddenParentNode, { attributes: true, childList: true, characterData: true, attributeFilter: ['style'] });
}
},
beforeDestroy() {
this.observer.removeListener(this.$refs.navWrap, this.handleResize);
Expand Down

0 comments on commit 7988575

Please sign in to comment.