| | |
| | | observer(newVal) { |
| | | if (newVal) { |
| | | let that = this; |
| | | let query = this.createSelectorQuery(); //必须要先创建一个查询 |
| | | 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, |
| | |
| | | |
| | | 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({ |
| | |
| | | }, |
| | | |
| | | 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 |
| | |
| | | return Math.atan2(y, x) * 180 / Math.PI |
| | | }, |
| | | touchEnd() { |
| | | console.log('touchEnd:'); |
| | | // console.log('touchEnd:'); |
| | | // 保存当前旋转角度,清空双指距离 |
| | | const oldRotate = this.data.rotate |
| | | this.setData({ |
| | |
| | | xLimit, |
| | | yLimit |
| | | }) |
| | | console.log('yLimit'); |
| | | console.log(yLimit); |
| | | // console.log('yLimit'); |
| | | // console.log(yLimit); |
| | | |
| | | let that = this; |
| | | let query = this.createSelectorQuery(); //必须要先创建一个查询 |
| | | 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(); |
| | | |
| | | // 缩放后回归至当前移动位置 |