Refactor on events
parent
69c37f7751
commit
c67bf1a764
|
@ -195,20 +195,12 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
enableDocumentSettings() {
|
enableDocumentSettings() {
|
||||||
if (this.modal) {
|
if (this.modal || (this.maximizable && this.maximized)) {
|
||||||
DomHandler.addClass(document.body, 'p-overflow-hidden');
|
|
||||||
this.bindDocumentKeydownListener();
|
|
||||||
}
|
|
||||||
else if (this.maximizable && this.maximized) {
|
|
||||||
DomHandler.addClass(document.body, 'p-overflow-hidden');
|
DomHandler.addClass(document.body, 'p-overflow-hidden');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
unbindDocumentState() {
|
unbindDocumentState() {
|
||||||
if (this.modal) {
|
if (this.modal || (this.maximizable && this.maximized)) {
|
||||||
DomHandler.removeClass(document.body, 'p-overflow-hidden');
|
|
||||||
this.unbindDocumentKeydownListener();
|
|
||||||
}
|
|
||||||
else if (this.maximizable && this.maximized) {
|
|
||||||
DomHandler.removeClass(document.body, 'p-overflow-hidden');
|
DomHandler.removeClass(document.body, 'p-overflow-hidden');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -240,13 +232,13 @@ export default {
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
bindDocumentKeydownListener() {
|
bindDocumentKeyDownListener() {
|
||||||
if (!this.documentKeydownListener) {
|
if (!this.documentKeydownListener) {
|
||||||
this.documentKeydownListener = this.onKeyDown.bind(this);
|
this.documentKeydownListener = this.onKeyDown.bind(this);
|
||||||
window.document.addEventListener('keydown', this.documentKeydownListener);
|
window.document.addEventListener('keydown', this.documentKeydownListener);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
unbindDocumentKeydownListener() {
|
unbindDocumentKeyDownListener() {
|
||||||
if (this.documentKeydownListener) {
|
if (this.documentKeydownListener) {
|
||||||
window.document.removeEventListener('keydown', this.documentKeydownListener);
|
window.document.removeEventListener('keydown', this.documentKeydownListener);
|
||||||
this.documentKeydownListener = null;
|
this.documentKeydownListener = null;
|
||||||
|
@ -309,10 +301,15 @@ export default {
|
||||||
this.bindDocumentDragListener();
|
this.bindDocumentDragListener();
|
||||||
this.bindDocumentDragEndListener();
|
this.bindDocumentDragEndListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.closeOnEscape && this.closable) {
|
||||||
|
this.bindDocumentKeyDownListener();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
unbindGlobalListeners() {
|
unbindGlobalListeners() {
|
||||||
this.unbindDocumentDragListener();
|
this.unbindDocumentDragListener();
|
||||||
this.unbindDocumentDragEndListener();
|
this.unbindDocumentDragEndListener();
|
||||||
|
this.unbindDocumentKeyDownListener();
|
||||||
},
|
},
|
||||||
bindDocumentDragListener() {
|
bindDocumentDragListener() {
|
||||||
this.documentDragListener = (event) => {
|
this.documentDragListener = (event) => {
|
||||||
|
|
Loading…
Reference in New Issue