2020-01-30 04:37:25 +09:00
|
|
|
<template>
|
2020-02-16 22:46:18 +09:00
|
|
|
<div class="mk-modal" v-hotkey.global="keymap">
|
2020-02-06 19:11:14 +09:00
|
|
|
<transition :name="$store.state.device.animation ? 'bg-fade' : ''" appear>
|
2020-07-12 18:14:59 +09:00
|
|
|
<div class="bg _modalBg" ref="bg" v-if="show" @click="canClose ? close() : () => {}"></div>
|
2020-01-30 04:37:25 +09:00
|
|
|
</transition>
|
2020-02-06 19:11:14 +09:00
|
|
|
<transition :name="$store.state.device.animation ? 'modal' : ''" appear @after-leave="() => { $emit('closed'); destroyDom(); }">
|
2020-07-11 10:13:11 +09:00
|
|
|
<div class="content" ref="content" v-if="show" @click.self="canClose ? close() : () => {}"><slot></slot></div>
|
2020-01-30 04:37:25 +09:00
|
|
|
</transition>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
props: {
|
2020-07-11 10:13:11 +09:00
|
|
|
canClose: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: true,
|
|
|
|
},
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
show: true,
|
|
|
|
};
|
|
|
|
},
|
2020-02-16 22:46:18 +09:00
|
|
|
computed: {
|
|
|
|
keymap(): any {
|
|
|
|
return {
|
|
|
|
'esc': this.close,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
2020-01-30 04:37:25 +09:00
|
|
|
methods: {
|
|
|
|
close() {
|
|
|
|
this.show = false;
|
|
|
|
(this.$refs.bg as any).style.pointerEvents = 'none';
|
|
|
|
(this.$refs.content as any).style.pointerEvents = 'none';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.modal-enter-active, .modal-leave-active {
|
|
|
|
transition: opacity 0.3s, transform 0.3s !important;
|
|
|
|
}
|
|
|
|
.modal-enter, .modal-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
transform: scale(0.9);
|
|
|
|
}
|
|
|
|
|
|
|
|
.bg-fade-enter-active, .bg-fade-leave-active {
|
|
|
|
transition: opacity 0.3s !important;
|
|
|
|
}
|
|
|
|
.bg-fade-enter, .bg-fade-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.mk-modal {
|
|
|
|
> .bg {
|
|
|
|
z-index: 10000;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .content {
|
|
|
|
position: fixed;
|
|
|
|
z-index: 10000;
|
|
|
|
top: 0;
|
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
max-width: calc(100% - 16px);
|
|
|
|
max-height: calc(100% - 16px);
|
|
|
|
overflow: auto;
|
|
|
|
margin: auto;
|
|
|
|
|
|
|
|
::v-deep > * {
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
margin: auto;
|
|
|
|
max-height: 100%;
|
|
|
|
max-width: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|