pull/525/head
Cagatay Civici 2020-09-28 14:34:45 +03:00
commit ed0fdc98a5
1 changed files with 20 additions and 0 deletions

View File

@ -56,6 +56,7 @@ export default {
}, },
mediumCheckRegExp: null, mediumCheckRegExp: null,
strongCheckRegExp: null, strongCheckRegExp: null,
resizeListener: null,
scrollHandler: null, scrollHandler: null,
overlay: null, overlay: null,
mounted() { mounted() {
@ -63,6 +64,7 @@ export default {
this.strongCheckRegExp = new RegExp(this.strongRegex); this.strongCheckRegExp = new RegExp(this.strongRegex);
}, },
beforeUnmount() { beforeUnmount() {
this.unbindResizeListener();
if (this.scrollHandler) { if (this.scrollHandler) {
this.scrollHandler.destroy(); this.scrollHandler.destroy();
this.scrollHandler = null; this.scrollHandler = null;
@ -74,9 +76,11 @@ export default {
this.overlay.style.minWidth = DomHandler.getOuterWidth(this.$refs.input) + 'px'; this.overlay.style.minWidth = DomHandler.getOuterWidth(this.$refs.input) + 'px';
DomHandler.absolutePosition(this.overlay, this.$refs.input); DomHandler.absolutePosition(this.overlay, this.$refs.input);
this.bindScrollListener(); this.bindScrollListener();
this.bindResizeListener();
}, },
onOverlayLeave() { onOverlayLeave() {
this.unbindScrollListener(); this.unbindScrollListener();
this.unbindResizeListener();
this.overlay = null; this.overlay = null;
}, },
testStrength(str) { testStrength(str) {
@ -156,6 +160,22 @@ export default {
this.scrollHandler.unbindScrollListener(); this.scrollHandler.unbindScrollListener();
} }
}, },
bindResizeListener() {
if (!this.resizeListener) {
this.resizeListener = () => {
if (this.overlayVisible) {
this.overlayVisible = false;
}
};
window.addEventListener('resize', this.resizeListener);
}
},
unbindResizeListener() {
if (this.resizeListener) {
window.removeEventListener('resize', this.resizeListener);
this.resizeListener = null;
}
},
overlayRef(el) { overlayRef(el) {
this.overlay = el; this.overlay = el;
} }