pull/3027/head^2
Tuğçe Küçükoğlu 2022-09-05 17:09:18 +03:00
parent ceecdf97d8
commit 20c1febcef
1 changed files with 21 additions and 0 deletions

View File

@ -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: {