自适应水印缩放

This commit is contained in:
yanran200730
2022-06-16 09:00:13 +08:00
parent 1d6b6cb0a9
commit 76df280f16

View File

@@ -12,7 +12,7 @@
<div <div
class="watermark" class="watermark"
v-if="currIndex > -1 && currWatermarkConfig.length" v-if="currIndex > -1 && currWatermarkConfig.length"
:style="{left: x + 'px', top: y + 'px' }" :style="{left: x + 'px', top: y + 'px', transform: 'scale(' + watermarkScale + ')' }"
@touchstart="onTouchstart" @touchstart="onTouchstart"
@touchmove="onTouchmove"> @touchmove="onTouchmove">
<component ref="WatermarkItem" :is="'Watermark' + (currIndex + 1)" :config="currWatermarkConfig"></component> <component ref="WatermarkItem" :is="'Watermark' + (currIndex + 1)" :config="currWatermarkConfig"></component>
@@ -155,6 +155,7 @@
x: 32, x: 32,
y: 24, y: 24,
startX: 0, startX: 0,
watermarkScale: 1,
startY: 0, startY: 0,
canvasHeight: 0 canvasHeight: 0
} }
@@ -224,6 +225,7 @@
const img = document.querySelector('.waterMarker-img') const img = document.querySelector('.waterMarker-img')
this.canvasHeight = img.clientHeight this.canvasHeight = img.clientHeight
this.watermarkScale = img.clientWidth / uni.getSystemInfoSync().windowWidth
}, },
onTouchstart (e) { onTouchstart (e) {