keydownFullImg (e) {
this.pageyUp = 0
this.pagexUp = 0
if (this.queryAllFaults.length < 1) {
this.keydownBoxArr = []
}
this.drawAreaImg = document.getElementById('fullImg')
var ev = e || window.event
var down = true // 定义一个标志,当滚轮向下滚时,执行一些操作
down = ev.wheelDelta ? ev.wheelDelta < 0 : ev.detail > 0
this.objY = e.layerY / this.drawAreaImg.height
this.objX = e.layerX / this.drawAreaImg.width
if (down) {
if (this.scalt <= 1.00) {
this.scalt = 1.00
return
} else {
this.scalt = (parseFloat(this.scalt) - 1).toFixed(2)
}
-------------------------------------------------------------------------
// 用于计算放大后的图片高度与放大之前高度的差,
let arrYo = this.drawAreaImg.height * this.scalt - this.drawAreaImg.height
let arrYt = 0.5 - (e.layerY / this.drawAreaImg.height)
let arrYz = arrYo * arrYt
let arrXo = this.drawAreaImg.width * this.scalt - this.drawAreaImg.width
let arrXt = 0.5 - (e.layerX / this.drawAreaImg.width)
let arrXz = arrXo * arrXt
-------------------------------------------------------------------------
this.arrXzfd = arrXz
this.arrYzfd = arrYz
this.drawAreaImg.style.transform = 'translate(' + arrXz + 'px, ' + arrYz + 'px)scale(' + this.scalt + ')'
// this.drawAreaImg.style.transform = 'scale(' + this.scalt + ')'
// this.drawAreaImg.style.transformOrigin = '50% 50%'
} else {
if (this.scalt >= 20.00) {
this.scalt = 20.00
return
} else {
this.scalt = (parseFloat(this.scalt) + 1).toFixed(2)
}
let arrYo = this.drawAreaImg.height * this.scalt - this.drawAreaImg.height
let arrYt = 0.5 - (e.layerY / this.drawAreaImg.height)
let arrYz = arrYo * arrYt
let arrXo = this.drawAreaImg.width * this.scalt - this.drawAreaImg.width
let arrXt = 0.5 - (e.layerX / this.drawAreaImg.width)
let arrXz = arrXo * arrXt
this.arrXzfd = arrXz
this.arrYzfd = arrYz
this.drawAreaImg.style.transform = 'translate(' + arrXz + 'px, ' + arrYz + 'px)scale(' + this.scalt + ')'
// this.drawAreaImg.style.transform = 'scale(' + this.scalt + ')'
// this.drawAreaImg.style.transformOrigin = '50% 50%'
}
this.boxArr = this.keydownBoxArr.map(item => {
return {
height: item.height * this.scalt,
// left: item.left * this.scalt - (this.drawAreaImg.width * this.scalt - this.drawAreaImg.width) / 2,
// top: item.top * this.scalt - (this.drawAreaImg.height * this.scalt - this.drawAreaImg.height) / 2,
left: item.left * this.scalt - (this.drawAreaImg.width * this.scalt - this.drawAreaImg.width) * this.objX,
top: item.top * this.scalt - (this.drawAreaImg.height * this.scalt - this.drawAreaImg.height) * this.objY,
width: item.width * this.scalt,
ids: item.ids,
isPutIn: item.isPutIn,
labelName: item.labelName,
source: item.source,
executionMethod: item.executionMethod
}
})
return false
},
根据指针放大缩小
最新推荐文章于 2025-05-29 10:17:42 发布