提交 f253edcb 编写于 作者: D dolymood

feat(Popup): support position and maskClosable

#221
上级 deef8e5d
...@@ -3,6 +3,10 @@ export default { ...@@ -3,6 +3,10 @@ export default {
zIndex: { zIndex: {
type: Number, type: Number,
default: 100 default: 100
},
maskClosable: {
type: Boolean,
default: false
} }
} }
} }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<div class="cube-popup-mask" @click="maskClick"> <div class="cube-popup-mask" @click="maskClick">
<slot name="mask"></slot> <slot name="mask"></slot>
</div> </div>
<div class="cube-popup-container" :class="{'cube-popup-center': center}"> <div class="cube-popup-container" :class="containerClass">
<div class="cube-popup-content" v-if="$slots.default"> <div class="cube-popup-content" v-if="$slots.default">
<slot></slot> <slot></slot>
</div> </div>
...@@ -38,6 +38,10 @@ ...@@ -38,6 +38,10 @@
center: { center: {
type: Boolean, type: Boolean,
default: true default: true
},
position: {
type: String,
default: ''
} }
}, },
computed: { computed: {
...@@ -49,11 +53,28 @@ ...@@ -49,11 +53,28 @@
cls[`cube-${this.type}`] = true cls[`cube-${this.type}`] = true
} }
return cls return cls
},
containerClass() {
const center = this.center
const position = this.position
if (position) {
return {
[`cube-popup-${position}`]: true
}
}
if (center) {
return {
'cube-popup-center': true
}
}
} }
}, },
methods: { methods: {
maskClick(e) { maskClick(e) {
this.$emit(EVENT_MASK_CLICK, e) this.$emit(EVENT_MASK_CLICK, e)
if (this.maskClosable) {
this.hide()
}
} }
} }
} }
...@@ -101,12 +122,33 @@ ...@@ -101,12 +122,33 @@
box-sizing: border-box box-sizing: border-box
transform: translate(-100%, -100%) transform: translate(-100%, -100%)
pointer-events: auto pointer-events: auto
.cube-popup-center .cube-popup-center,
.cube-popup-right,
.cube-popup-left
.cube-popup-content .cube-popup-content
position: absolute
top: -50% top: -50%
left: -50% left: -50%
width: auto width: auto
max-width: 100% max-width: 100%
transform: translate(-50%, -50%) transform: translate(0, 0)
.cube-popup-right,
.cube-popup-left
.cube-popup-content
height: 100%
top: -100%
.cube-popup-center
.cube-popup-content
transform: translate(-50%, -50%)
.cube-popup-top
.cube-popup-content
top: -100%
left: -100%
transform: translate(0, 0)
.cube-popup-right
.cube-popup-content
top: -100%
right: 100%
.cube-popup-left
.cube-popup-content
left: -100%
</style> </style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册