根据指针放大缩小

    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
    },

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值