riku
2024-11-13 48145f787eda81815f653ad21161a60e89b6a303
component/mygallery/mygallery.js
@@ -33,8 +33,8 @@
          let query = this.createSelectorQuery().in(this); //必须要先创建一个查询
          setTimeout(() => {
            query.select('.fyui-gallery__img').boundingClientRect(function (rect) {
              console.log('observer');
              console.log(rect);
              // console.log('observer');
              // console.log(rect);
              that.setData({
                imgHeight: rect.height,
                imgWidth: rect.width,
@@ -195,8 +195,8 @@
    touchStart(e) {
      const touches = e.touches
      console.log('touchStart:');
      console.log(touches);
      // console.log('touchStart:');
      // console.log(touches);
      const { translateX, translateY } = this.data
      const { clientX, clientY } = touches[0]
      this.setData({
@@ -211,7 +211,7 @@
    },
    
    touchMove(e) {
      console.log('touchMove:');
      // console.log('touchMove:');
      const touches = e.touches
      const { clientX: onePageX, clientY: onePageY } = touches[0]
      const { startMove, scale, distance: oldDistance, startTouches, oldRotate  } = this.data
@@ -259,7 +259,7 @@
      return Math.atan2(y, x) * 180 / Math.PI
    },
    touchEnd() {
      console.log('touchEnd:');
      // console.log('touchEnd:');
      // 保存当前旋转角度,清空双指距离
      const oldRotate = this.data.rotate
      this.setData({ 
@@ -294,16 +294,16 @@
        xLimit,
        yLimit
      })
      console.log('yLimit');
      console.log(yLimit);
      // console.log('yLimit');
      // console.log(yLimit);
      let that = this;
      let query = this.createSelectorQuery().in(this); //必须要先创建一个查询
      query.select('.fyui-gallery__img').boundingClientRect(function (rect) {
        console.log('imgHeight:' + that.data.imgHeight);
        console.log('imgWidth:' + that.data.imgWidth);
        console.log(rect);
        console.log('endScale:' + that.data.endScale);
        // console.log('imgHeight:' + that.data.imgHeight);
        // console.log('imgWidth:' + that.data.imgWidth);
        // console.log(rect);
        // console.log('endScale:' + that.data.endScale);
      }).exec();
      // 缩放后回归至当前移动位置