123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <template>
- <view class="u-mask" :style="[maskStyle]" :class="[show ? 'u-mask-show' : '']" @tap="click" @touchmove.stop.prevent>
- <slot />
- </view>
- </template>
- <script>
-
- export default {
- name: "u-mask",
- props: {
-
- show: {
- type: Boolean,
- default: false
- },
-
- zIndex: {
- type: [Number, String],
- default: '1'
- },
-
- customStyle: {
- type: Object,
- default () {
- return {}
- }
- },
-
- zoom: {
- type: Boolean,
- default: true
- },
-
- duration: {
- type: [Number, String],
- default: 300
- },
-
- maskClickAble: {
- type: Boolean,
- default: true
- }
- },
- computed: {
- maskStyle() {
- let style = {};
- style.backgroundColor = "rgba(0, 0, 0, 0.6)";
- style.zIndex = this.zIndex ? this.zIndex : this.$u.zIndex.mask;
- style.transition = `all ${this.duration / 1000}s ease-in-out`;
-
-
-
- if (Object.keys(this.customStyle).length) style = { ...style,
- ...this.customStyle
- };
-
-
- return style;
- }
- },
- methods: {
- click() {
- if (!this.maskClickAble) return;
- this.$emit('click');
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .u-mask {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- opacity: 0;
- visibility: hidden;
- }
- .u-mask-show {
- opacity: 1;
- visibility: visible;
- transform: scale(1);
- }
- </style>
|