pull/4859/head
tugcekucukoglu 2023-11-21 20:28:15 +03:00
parent 1aff573453
commit 9ae8d5b413
1 changed files with 25 additions and 7 deletions

View File

@ -520,6 +520,7 @@ export default {
outsideClickListener: null,
maskClickListener: null,
resizeListener: null,
matchMediaListener: null,
overlay: null,
input: null,
mask: null,
@ -539,6 +540,7 @@ export default {
focused: false,
overlayVisible: false,
currentView: this.view,
query: null,
queryMatches: false
};
},
@ -589,13 +591,7 @@ export default {
},
mounted() {
this.createResponsiveStyle();
const query = matchMedia(`(max-width: ${this.breakpoint})`);
this.queryMatches = query.matches;
query.addEventListener('change', () => {
this.queryMatches = query.matches;
});
this.bindMatchMediaListener();
if (this.inline) {
this.overlay && this.overlay.setAttribute(this.attributeSelector, '');
@ -638,6 +634,7 @@ export default {
this.unbindOutsideClickListener();
this.unbindResizeListener();
this.unbindMatchMediaListener();
if (this.scrollHandler) {
this.scrollHandler.destroy();
@ -1022,6 +1019,27 @@ export default {
this.resizeListener = null;
}
},
bindMatchMediaListener() {
if (!this.matchMediaListener) {
const query = matchMedia(`(max-width: ${this.breakpoint})`);
this.query = query;
this.queryMatches = query.matches;
this.matchMediaListener = () => {
this.queryMatches = query.matches;
this.mobileActive = false;
};
this.query.addEventListener('change', this.matchMediaListener);
}
},
unbindMatchMediaListener() {
if (this.matchMediaListener) {
this.query.removeEventListener('change', this.matchMediaListener);
this.matchMediaListener = null;
}
},
isOutsideClicked(event) {
return !(this.$el.isSameNode(event.target) || this.isNavIconClicked(event) || this.$el.contains(event.target) || (this.overlay && this.overlay.contains(event.target)));
},