Refactor #4821
parent
9ae8d5b413
commit
d5742af12c
|
@ -11,19 +11,41 @@ import DockSub from './DockSub.vue';
|
|||
export default {
|
||||
name: 'Dock',
|
||||
extends: BaseDock,
|
||||
matchMediaListener: null,
|
||||
data() {
|
||||
return {
|
||||
query: null,
|
||||
queryMatches: false
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.bindMatchMediaListener();
|
||||
},
|
||||
beforeUnmount() {
|
||||
this.unbindMatchMediaListener();
|
||||
},
|
||||
methods: {
|
||||
bindMatchMediaListener() {
|
||||
if (!this.matchMediaListener) {
|
||||
const query = matchMedia(`(max-width: ${this.breakpoint})`);
|
||||
|
||||
this.query = query;
|
||||
this.queryMatches = query.matches;
|
||||
|
||||
query.addEventListener('change', () => {
|
||||
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;
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
containerClass() {
|
||||
|
|
Loading…
Reference in New Issue