mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
image preview component
This commit is contained in:
parent
c794949c8d
commit
1cf5490f99
@ -1,5 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="page-image-pewview">
|
|
||||||
<h1 class="page-title">Image Preview</h1>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
18
docs/examples/image-preview.vue
Normal file
18
docs/examples/image-preview.vue
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<template>
|
||||||
|
<div class="page-image-pewview">
|
||||||
|
<h1 class="page-title">Image Preview</h1>
|
||||||
|
|
||||||
|
<h2 class="page-sub-title">基础用法</h2>
|
||||||
|
<zan-image-preview v-model="preview"></zan-image-preview>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
preview: true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
@ -131,7 +131,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "/image-preview",
|
"path": "/image-preview",
|
||||||
"title": "ImagePreview 图片预览"
|
"title": "ImagePreview"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -70,10 +70,8 @@ export default {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (this.modal && this.bodyOverflow !== 'hidden') {
|
if (this.modal && this.bodyOverflow !== 'hidden') {
|
||||||
document.body.style.overflow = this.bodyOverflow;
|
document.body.style.overflow = this.bodyOverflow;
|
||||||
document.body.style.paddingRight = this.bodyPaddingRight;
|
|
||||||
}
|
}
|
||||||
this.bodyOverflow = null;
|
this.bodyOverflow = null;
|
||||||
this.bodyPaddingRight = null;
|
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
import ImagePreview from './src/image-preview';
|
import ImagePreview from './src/image-preview.vue';
|
||||||
|
|
||||||
export default ImagePreview;
|
export default ImagePreview;
|
||||||
|
0
packages/image-preview/src/image-preview.js
Normal file
0
packages/image-preview/src/image-preview.js
Normal file
@ -1,18 +1,73 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<transition name="image-fade">
|
||||||
<h2>author: {{ author }}</h2>
|
<div class="zan-image-preview" ref="previewContainer" v-show="value">
|
||||||
<div>Hello {{ name }}</div>
|
<img class="zan-image-preview__image" :src="image" alt="" :style="imageStyle">
|
||||||
</div>
|
</div>
|
||||||
|
</transition>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
import Popup from 'src/mixins/popup';
|
||||||
name: 'Sample',
|
|
||||||
props: ['author'],
|
export default {
|
||||||
data() {
|
name: 'zan-image-preview',
|
||||||
return {
|
|
||||||
name: 'World'
|
mixins: [Popup],
|
||||||
};
|
|
||||||
|
props: {
|
||||||
|
overlay: {
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
|
||||||
|
lockOnScroll: {
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
|
||||||
|
closeOnClickOverlay: {
|
||||||
|
default: true
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
image: 'https://img.yzcdn.cn/upload_files/2017/03/02/FhDtQ7okM18PeQ3P0RAfIzVADUEq.jpg'
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
mounted() {
|
||||||
|
this.open();
|
||||||
|
this.previewSize = this.$refs.previewContainer.getBoundingClientRect();
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
/**
|
||||||
|
* 图片样式计算
|
||||||
|
* 根据屏幕自适应显示最长边
|
||||||
|
*/
|
||||||
|
imageStyle() {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
close() {
|
||||||
|
if (this.closing) return;
|
||||||
|
|
||||||
|
this.closing = true;
|
||||||
|
|
||||||
|
this.value = false;
|
||||||
|
|
||||||
|
if (this.lockOnScroll) {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (this.modal && this.bodyOverflow !== 'hidden') {
|
||||||
|
document.body.style.overflow = this.bodyOverflow;
|
||||||
|
}
|
||||||
|
this.bodyOverflow = null;
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.opened = false;
|
||||||
|
this.doAfterClose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
15
packages/zanui-css/src/image_preview.css
Normal file
15
packages/zanui-css/src/image_preview.css
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
@component-namespace zan {
|
||||||
|
@b image-preview {
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
height: 75%;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
@e image {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -19,3 +19,4 @@
|
|||||||
@import './steps.css';
|
@import './steps.css';
|
||||||
@import './tag.css';
|
@import './tag.css';
|
||||||
@import './checkbox.css';
|
@import './checkbox.css';
|
||||||
|
@import './image_preview.css';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user