fix issue #1846
This commit is contained in:
parent
7a9f6b28fc
commit
79885751e2
1 changed files with 22 additions and 0 deletions
|
@ -310,6 +310,16 @@
|
||||||
},
|
},
|
||||||
handleResize(){
|
handleResize(){
|
||||||
this.updateNavScroll();
|
this.updateNavScroll();
|
||||||
|
},
|
||||||
|
isInsideHiddenElement () {
|
||||||
|
let parentNode = this.$el.parentNode;
|
||||||
|
while(parentNode) {
|
||||||
|
if (parentNode.style.display === 'none') {
|
||||||
|
return parentNode;
|
||||||
|
}
|
||||||
|
parentNode = parentNode.parentNode;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -329,6 +339,18 @@
|
||||||
this.showSlot = this.$slots.extra !== undefined;
|
this.showSlot = this.$slots.extra !== undefined;
|
||||||
this.observer = elementResizeDetectorMaker();
|
this.observer = elementResizeDetectorMaker();
|
||||||
this.observer.listenTo(this.$refs.navWrap, this.handleResize);
|
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() {
|
beforeDestroy() {
|
||||||
this.observer.removeListener(this.$refs.navWrap, this.handleResize);
|
this.observer.removeListener(this.$refs.navWrap, this.handleResize);
|
||||||
|
|
Loading…
Add table
Reference in a new issue