vue图片手指缩放

vue图片手指缩放

touchstart (event) {
      // this.touchelength = event.touches.length
      // event.preventDefault() // 默认事件  长按复制
      // if (event.touches.length > 1) {
      //   this.isDoubleTouch = true
      //   this.windowWidth = this.isDoubleTouch
      //   this.startTouches = event.touches
      //   // this.windowWidth = event.touches.length
      // } else {
      //   this.startX = event.changedTouches[0].pageX
      //   this.startY = event.changedTouches[0].pageY
      // }
    },
    touchmove (event) {
      if (this.isDoubleTouch) {
        // const now = event.touches
        // const start = this.startTouches
        // const st = this.getDistance(now[0], now[1])
        // const sy = this.getDistance(start[0], start[1])
        // if (this.scale > 3) {
        //   this.scale = 3
        //   return
        // }
        // if (this.scale < 1) {
        //   this.scale = 1
        //   return
        // }
        // this.scale = this.getDistance(now[0], now[1]) / this.getDistance(start[0], start[1]) // 缩放比例
        // this.windowWidth = this.scale
      }
      getDistance (p1, p2) {
      if (this.scale >= 1 <= 3) {
        var x = p2.pageX - p1.pageX
        var y = p2.pageY - p1.pageY
        return Math.sqrt((x * x) + (y * y))
      }
    },
    touchend (event) {
      const moveEndX = event.changedTouches[0].pageX
      const moveEndY = event.changedTouches[0].pageY
      const X = moveEndX - this.startX
      const Y = moveEndY - this.startY
      if (this.scale > 1) {
        return
      }
      if (Math.abs(X) > Math.abs(Y) && X > 100) {
        this.upPrev()
      } else if (Math.abs(X) > Math.abs(Y) && X < -100) {
        this.nextQuiz()
      }
    },
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值