mand-mobile/components/landscape/index.vue

125 lines
2.3 KiB
Vue
Raw Normal View History

2018-03-26 16:04:04 +08:00
<template>
<div class="md-landscape" :class="{'is-full': fullScreen}">
2018-03-26 16:04:04 +08:00
<md-popup
v-model="isLandscapeShow"
:mask-closable="maskClosable"
2018-03-26 16:04:04 +08:00
prevent-scroll
:prevent-scroll-exclude="scroll ? '.landscape-content' : null"
:has-mask="!fullScreen && hasMask"
:transition="fullScreen ? 'md-zoom' : 'md-punch'"
2018-03-26 16:04:04 +08:00
@input="$emit('input', false)"
@show="$emit('show')"
@hide="$emit('hide')">
<div class="landscape-content" :class="{scroll}">
2018-03-26 16:04:04 +08:00
<slot></slot>
</div>
</md-popup>
<div class="landscape-close"
2018-03-26 16:04:04 +08:00
@click="$_close"
v-show="isLandscapeShow"
:class="{dark: !hasMask || fullScreen}">
2018-10-15 16:01:59 +08:00
<md-icon name="close"></md-icon>
2018-03-26 16:04:04 +08:00
</div>
</div>
</template>
<script> import Popup from '../popup'
import Icon from '../icon'
export default {
name: 'md-landscape',
components: {
[Popup.name]: Popup,
[Icon.name]: Icon,
},
props: {
value: {
type: Boolean,
default: false,
},
scroll: {
type: Boolean,
default: false,
},
fullScreen: {
type: Boolean,
default: false,
},
2018-03-26 16:04:04 +08:00
hasMask: {
type: Boolean,
default: true,
},
maskClosable: {
type: Boolean,
default: false,
},
2018-03-26 16:04:04 +08:00
},
data() {
return {
isLandscapeShow: this.value,
}
},
watch: {
value(val) {
this.isLandscapeShow = val
},
},
methods: {
// MARK: private methods
$_close() {
this.isLandscapeShow = false
},
},
}
</script>
<style lang="stylus">
.md-landscape
&.is-full
2018-09-28 15:37:15 +08:00
.md-popup-box
position absolute
absolute-pos()
background landscape-fullscreen-bg
.landscape-content
width 100%
height 100%
2018-11-11 12:17:35 +08:00
.md-popup
z-index landscape-zindex
.landscape-content
display flex
justify-content center
align-items center
2018-03-26 16:04:04 +08:00
position relative
width landscape-width
font-size font-body-large
2018-03-26 16:04:04 +08:00
text-align center
border-radius landscape-radius
overflow hidden
2018-03-26 16:04:04 +08:00
>img
width 100%
height 100%
display block
&.scroll
max-height 700px
overflow-y scroll
.landscape-close
2018-03-26 16:04:04 +08:00
position fixed
z-index landscape-zindex
2018-03-26 16:04:04 +08:00
left 0
right 0
bottom 10%
color color-text-base-inverse
text-align center
2018-03-26 16:04:04 +08:00
&.dark
color color-text-base
.md-icon
2018-10-15 16:01:59 +08:00
font-size 50px
2018-03-26 16:04:04 +08:00
</style>