pull/193/head
mertsincan 2020-02-03 12:44:20 +03:00
parent d2239751f7
commit 8447b3892f
1 changed files with 23 additions and 19 deletions

View File

@ -79,7 +79,7 @@ export default {
this.removeStylesFromMask(); this.removeStylesFromMask();
}, },
beforeDestroy() { beforeDestroy() {
this.disableModality(); this.disableDocumentSettings();
}, },
methods: { methods: {
close() { close() {
@ -95,14 +95,14 @@ export default {
this.$emit('show'); this.$emit('show');
this.focus(); this.focus();
this.enableModality(); this.enableDocumentSettings();
}, },
onLeave() { onLeave() {
this.$emit('hide'); this.$emit('hide');
}, },
onAfterLeave() { onAfterLeave() {
this.maskVisible = false; this.maskVisible = false;
this.disableModality(); this.disableDocumentSettings();
}, },
onAppear() { onAppear() {
if (this.visible) { if (this.visible) {
@ -115,28 +115,32 @@ export default {
focusable.focus(); focusable.focus();
} }
}, },
enableModality() {
if (this.modal) {
DomHandler.addClass(document.body, 'p-overflow-hidden');
this.bindDocumentKeydownListener();
}
},
disableModality() {
if (this.modal) {
DomHandler.removeClass(document.body, 'p-overflow-hidden');
this.unbindDocumentKeydownListener();
}
},
maximize() { maximize() {
this.maximized = !this.maximized; this.maximized = !this.maximized;
if (!this.modal) { if (!this.modal) {
if (this.maximized) { if (this.maximized)
DomHandler.addClass(document.body, 'p-overflow-hidden'); DomHandler.addClass(document.body, 'p-overflow-hidden');
} else
else {
DomHandler.removeClass(document.body, 'p-overflow-hidden'); DomHandler.removeClass(document.body, 'p-overflow-hidden');
} }
},
enableDocumentSettings() {
if (this.modal) {
DomHandler.addClass(document.body, 'p-overflow-hidden');
this.bindDocumentKeydownListener();
}
else if (this.maximizable && this.maximized) {
DomHandler.addClass(document.body, 'p-overflow-hidden');
}
},
disableDocumentSettings() {
if (this.modal) {
DomHandler.removeClass(document.body, 'p-overflow-hidden');
this.unbindDocumentKeydownListener();
}
else if (this.maximizable && this.maximized) {
DomHandler.removeClass(document.body, 'p-overflow-hidden');
} }
}, },
onKeyDown(event) { onKeyDown(event) {