#237 for Dialog - Animate modal background

pull/256/head
cagataycivici 2020-03-17 12:51:52 +03:00
parent 805b312fbc
commit 382a51c036
1 changed files with 17 additions and 4 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<div ref="mask" :class="maskClass" v-if="maskVisible"> <div ref="mask" :class="maskClass" v-if="maskVisible">
<transition name="p-dialog" @before-enter="onBeforeEnter" @enter="onEnter" @leave="onLeave" @after-leave="onAfterLeave" @appear="onAppear"> <transition name="p-dialog" @before-enter="onBeforeEnter" @enter="onEnter" @before-leave="onBeforeLeave" @leave="onLeave" @after-leave="onAfterLeave" @appear="onAppear">
<div ref="dialog" :class="dialogClass" :style="dialogStyle" v-if="visible" v-bind="$attrs" v-on="listeners" role="dialog" :aria-labelledby="ariaLabelledById" :aria-modal="modal"> <div ref="dialog" :class="dialogClass" :style="dialogStyle" v-if="visible" v-bind="$attrs" v-on="listeners" role="dialog" :aria-labelledby="ariaLabelledById" :aria-modal="modal">
<div class="p-dialog-titlebar" v-if="showHeader"> <div class="p-dialog-titlebar" v-if="showHeader">
<slot name="header"> <slot name="header">
@ -78,6 +78,10 @@ export default {
if (this.visible && !this.maskVisible) { if (this.visible && !this.maskVisible) {
this.maskVisible = true; this.maskVisible = true;
} }
if (this.modal && this.$refs.mask && !DomHandler.hasClass(this.$refs.mask, 'p-component-overlay')) {
DomHandler.addClass(this.$refs.mask, 'p-component-overlay');
}
}, },
mounted() { mounted() {
this.removeStylesFromMask(); this.removeStylesFromMask();
@ -101,6 +105,9 @@ export default {
this.focus(); this.focus();
this.enableDocumentSettings(); this.enableDocumentSettings();
}, },
onBeforeLeave() {
DomHandler.addClass(this.$refs.mask, 'p-dialog-mask-leave');
},
onLeave() { onLeave() {
this.$emit('hide'); this.$emit('hide');
}, },
@ -214,9 +221,7 @@ export default {
}; };
}, },
maskClass() { maskClass() {
return ['p-dialog-mask', { return ['p-dialog-mask', this.getPositionClass()];
'p-component-overlay': this.modal,
}, this.getPositionClass()];
}, },
dialogClass() { dialogClass() {
return ['p-dialog p-component', { return ['p-dialog p-component', {
@ -253,6 +258,9 @@ export default {
justify-content: center; justify-content: center;
align-items: center; align-items: center;
pointer-events: none; pointer-events: none;
background-color: transparent;
transition-property: background-color;
transition-duration: 150ms;
} }
.p-dialog-mask.p-component-overlay { .p-dialog-mask.p-component-overlay {
pointer-events: auto; pointer-events: auto;
@ -364,6 +372,11 @@ export default {
opacity: 0; opacity: 0;
transform: scale(0.7); transform: scale(0.7);
} }
.p-dialog-mask.p-dialog-mask-leave {
background-color: transparent;
}
/* Top, Bottom, Left, Right, Top* and Bottom* */ /* Top, Bottom, Left, Right, Top* and Bottom* */
.p-dialog-top .p-dialog, .p-dialog-top .p-dialog,
.p-dialog-bottom .p-dialog, .p-dialog-bottom .p-dialog,