不等比缩放
This commit is contained in:
@@ -296,7 +296,7 @@ export default defineComponent({
|
||||
w = (e.changedTouches[0].pageX -imgDomWH.left)
|
||||
h = (e.changedTouches[0].pageX -imgDomWH.left)*num
|
||||
width = w+'px'
|
||||
height = w*num+'px'
|
||||
// height = w*num+'px'
|
||||
}else if(this.direction == 'top'){
|
||||
num = width/height
|
||||
this.frontBack.front[this.imgDomIndex].style.top = 'auto'
|
||||
@@ -307,18 +307,18 @@ export default defineComponent({
|
||||
h = (this.frontBack.front[this.imgDomIndex].centers.top - e.changedTouches[0].pageY)
|
||||
|
||||
height = h+'px'
|
||||
width = h*num+'px'
|
||||
// width = h*num+'px'
|
||||
}else if(this.direction == 'bottom'){
|
||||
num = width/height
|
||||
h = (e.changedTouches[0].pageY -imgDomWH.top)
|
||||
height = h+'px'
|
||||
width = h*num+'px'
|
||||
// width = h*num+'px'
|
||||
}else if(this.direction == 'left'){
|
||||
w = (this.frontBack.front[this.imgDomIndex].centers.left - e.changedTouches[0].pageX)
|
||||
this.frontBack.front[this.imgDomIndex].style.left = 'auto'
|
||||
this.frontBack.front[this.imgDomIndex].style.right = this.frontBack.front[this.imgDomIndex].centers.right+'px'
|
||||
width = w+'px'
|
||||
height = w*num+'px'
|
||||
// height = w*num+'px'
|
||||
}
|
||||
//判断尺寸是否到边
|
||||
this.frontBack.front[this.imgDomIndex].style.width = width
|
||||
@@ -403,12 +403,13 @@ export default defineComponent({
|
||||
imageCategory1 = arr[1].imageCategory
|
||||
}
|
||||
arr.forEach((i)=>{
|
||||
let imageCategory = i.imageCategory.split('_')[0]
|
||||
if(item.id == i.id){
|
||||
let y = ((i?.style?.top.replace(/px/g,'')*ratio).toFixed(0) - i?.position[0])
|
||||
let x = ((i?.style?.left.replace(/px/g,'')*ratio).toFixed(0) - i?.position[1])
|
||||
let scale = i?.imageSize?Number(((i?.style?.width.replace(/px/g,'')*ratio)/(i?.imageSize[0]/i.scale)).toFixed(2)):1
|
||||
item.scale = scale
|
||||
// let scale = i?.imageSize?Number(((i?.style?.width.replace(/px/g,'')*ratio)/(i?.imageSize[0]/i.scale)).toFixed(2)):1
|
||||
let scaleWidth = i?.imageSize?Number(((i?.style?.width.replace(/px/g,'')*ratio)/(i?.imageSize[0]/i.scale[0])).toFixed(2)):1
|
||||
let scaleHeight = i?.imageSize?Number(((i?.style?.height.replace(/px/g,'')*ratio)/(i?.imageSize[1]/i.scale[1])).toFixed(2)):1
|
||||
item.scale = [scaleWidth,scaleHeight]
|
||||
let top = y == 0 ? item.offset[1]:y+item.offset[1]
|
||||
let left = x == 0 ? item.offset[0]:x+item.offset[0]
|
||||
item.offset = [left,top]
|
||||
|
||||
Reference in New Issue
Block a user