Refactor #2919
parent
ceecdf97d8
commit
20c1febcef
|
@ -10,16 +10,22 @@ export default {
|
|||
value: null,
|
||||
autoResize: Boolean
|
||||
},
|
||||
resizeListener: null,
|
||||
mounted() {
|
||||
if (this.$el.offsetParent && this.autoResize) {
|
||||
this.resize();
|
||||
this.bindResizeListener();
|
||||
}
|
||||
},
|
||||
updated() {
|
||||
if (DomHandler.isVisible(this.$el) && this.$el.offsetParent.tagName !== 'BODY' && this.autoResize) {
|
||||
this.resize();
|
||||
this.bindResizeListener();
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.unbindResizeListener();
|
||||
},
|
||||
methods: {
|
||||
resize() {
|
||||
const style = window.getComputedStyle(this.$el);
|
||||
|
@ -34,6 +40,21 @@ export default {
|
|||
else {
|
||||
this.$el.style.overflow = "hidden";
|
||||
}
|
||||
},
|
||||
bindResizeListener() {
|
||||
if (!this.resizeListener) {
|
||||
this.resizeListener = () => {
|
||||
this.resize();
|
||||
};
|
||||
|
||||
window.addEventListener('resize', this.resizeListener);
|
||||
}
|
||||
},
|
||||
unbindResizeListener() {
|
||||
if (this.resizeListener) {
|
||||
window.removeEventListener('resize', this.resizeListener);
|
||||
this.resizeListener = null;
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
|
Loading…
Reference in New Issue