|
@@ -13,7 +13,7 @@
|
|
|
<Icon type="ios-close" />
|
|
|
</div>
|
|
|
|
|
|
- <div :class="[`${prefixCls}-body`]" ref="ReviewBody" @click="cancel">
|
|
|
+ <div :class="[`${prefixCls}-body`]" ref="ReviewBody">
|
|
|
<div
|
|
|
:class="[`${prefixCls}-guide`, `${prefixCls}-guide-prev`]"
|
|
|
@click.stop="showPrev"
|
|
@@ -32,6 +32,7 @@
|
|
|
{ [`${prefixCls}-imgs-nosition`]: nosition }
|
|
|
]"
|
|
|
:style="styles"
|
|
|
+ v-move-ele.prevent.stop="{ mouseMove, mouseWheel }"
|
|
|
v-if="modalIsShow"
|
|
|
>
|
|
|
<img
|
|
@@ -54,6 +55,27 @@
|
|
|
|
|
|
<div :class="[`${prefixCls}-footer`]">
|
|
|
<ul>
|
|
|
+ <li title="合适大小" @click="toOrigin">
|
|
|
+ <Icon type="md-expand" />
|
|
|
+ </li>
|
|
|
+ <li
|
|
|
+ title="放大"
|
|
|
+ @click="toMagnify"
|
|
|
+ :class="{
|
|
|
+ 'li-disabled': transform.scale === maxScale
|
|
|
+ }"
|
|
|
+ >
|
|
|
+ <Icon type="md-add-circle" />
|
|
|
+ </li>
|
|
|
+ <li
|
|
|
+ title="缩小"
|
|
|
+ @click="toShrink"
|
|
|
+ :class="{
|
|
|
+ 'li-disabled': transform.scale === minScale
|
|
|
+ }"
|
|
|
+ >
|
|
|
+ <Icon type="md-remove-circle" />
|
|
|
+ </li>
|
|
|
<li title="旋转" @click.stop="toRotate">
|
|
|
<Icon type="ios-refresh-circle" />
|
|
|
</li>
|
|
@@ -63,6 +85,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import MoveEle from "./common/ImagePreview/move-ele";
|
|
|
const prefixCls = "cc-image-preview";
|
|
|
|
|
|
export default {
|
|
@@ -75,12 +98,15 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ directives: { MoveEle },
|
|
|
data() {
|
|
|
return {
|
|
|
prefixCls,
|
|
|
modalIsShow: false,
|
|
|
styles: { width: "", height: "", top: "", left: "", transform: "" },
|
|
|
initWidth: 500,
|
|
|
+ minScale: 0.2,
|
|
|
+ maxScale: 3,
|
|
|
transform: {
|
|
|
scale: 1,
|
|
|
rotate: 0
|
|
@@ -108,6 +134,9 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ mounted() {
|
|
|
+ this.registWheelHandle();
|
|
|
+ },
|
|
|
methods: {
|
|
|
visibleChange(visible) {
|
|
|
if (!visible) return;
|
|
@@ -208,10 +237,42 @@ export default {
|
|
|
// this.initData();
|
|
|
},
|
|
|
// dome-move
|
|
|
+ registWheelHandle() {
|
|
|
+ this.$refs.ReviewBody.addEventListener("wheel", e => {
|
|
|
+ e.preventDefault();
|
|
|
+ this.mouseWheel(e.wheelDeltaY);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ mouseMove({ left, top }) {
|
|
|
+ this.styles.left = left + "px";
|
|
|
+ this.styles.top = top + "px";
|
|
|
+ },
|
|
|
+ mouseWheel(delta) {
|
|
|
+ if (delta < 0) {
|
|
|
+ this.toMagnify();
|
|
|
+ } else {
|
|
|
+ this.toShrink();
|
|
|
+ }
|
|
|
+ },
|
|
|
setStyleTransform() {
|
|
|
const { scale, rotate } = this.transform;
|
|
|
this.styles.transform = `scale(${scale}, ${scale}) rotate(${rotate}deg)`;
|
|
|
},
|
|
|
+ toOrigin() {
|
|
|
+ this.transform.scale = 1;
|
|
|
+ this.setStyleTransform();
|
|
|
+ this.reizeImage();
|
|
|
+ },
|
|
|
+ toMagnify() {
|
|
|
+ const scale = (this.transform.scale * 1.2).toFixed(2);
|
|
|
+ this.transform.scale = scale >= this.maxScale ? this.maxScale : scale;
|
|
|
+ this.setStyleTransform();
|
|
|
+ },
|
|
|
+ toShrink() {
|
|
|
+ const scale = (this.transform.scale * 0.75).toFixed(2);
|
|
|
+ this.transform.scale = scale <= this.minScale ? this.minScale : scale;
|
|
|
+ this.setStyleTransform();
|
|
|
+ },
|
|
|
toRotate() {
|
|
|
this.transform.rotate = this.transform.rotate + 90;
|
|
|
this.setStyleTransform();
|