Resize listener for OverlayPanel
parent
65562cda09
commit
3231c569ed
|
@ -41,8 +41,10 @@ export default {
|
||||||
},
|
},
|
||||||
target: null,
|
target: null,
|
||||||
outsideClickListener: null,
|
outsideClickListener: null,
|
||||||
|
resizeListener: null,
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
this.restoreAppend();
|
this.restoreAppend();
|
||||||
|
this.unbindResizeListener();
|
||||||
if (this.dismissable) {
|
if (this.dismissable) {
|
||||||
this.unbindOutsideClickListener();
|
this.unbindOutsideClickListener();
|
||||||
}
|
}
|
||||||
|
@ -65,19 +67,16 @@ export default {
|
||||||
onEnter() {
|
onEnter() {
|
||||||
this.appendContainer();
|
this.appendContainer();
|
||||||
this.alignOverlay();
|
this.alignOverlay();
|
||||||
|
this.bindOutsideClickListener();
|
||||||
if (this.dismissable) {
|
this.bindResizeListener();
|
||||||
this.bindOutsideClickListener();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.autoZIndex) {
|
if (this.autoZIndex) {
|
||||||
this.$refs.container.style.zIndex = String(this.baseZIndex + DomHandler.generateZIndex());
|
this.$refs.container.style.zIndex = String(this.baseZIndex + DomHandler.generateZIndex());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLeave() {
|
onLeave() {
|
||||||
if (this.dismissable) {
|
this.unbindOutsideClickListener();
|
||||||
this.unbindOutsideClickListener();
|
this.unbindResizeListener();
|
||||||
}
|
|
||||||
},
|
},
|
||||||
alignOverlay() {
|
alignOverlay() {
|
||||||
DomHandler.absolutePosition(this.$refs.container, this.target);
|
DomHandler.absolutePosition(this.$refs.container, this.target);
|
||||||
|
@ -102,6 +101,23 @@ export default {
|
||||||
this.outsideClickListener = null;
|
this.outsideClickListener = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
bindResizeListener() {
|
||||||
|
if (!this.resizeListener) {
|
||||||
|
this.resizeListener = (event) => {
|
||||||
|
console.log('x');
|
||||||
|
if (this.visible) {
|
||||||
|
this.visible = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
window.addEventListener('resize', this.resizeListener);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
unbindResizeListener() {
|
||||||
|
if (this.resizeListener) {
|
||||||
|
window.removeEventListener('resize', this.resizeListener);
|
||||||
|
this.resizeListener = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
isTargetClicked() {
|
isTargetClicked() {
|
||||||
return this.target && (this.target === event.target || this.target.contains(event.target));
|
return this.target && (this.target === event.target || this.target.contains(event.target));
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue