使用场景:选择头像框生成对应头像;
功能:可移动、缩放、旋转;
catchtouchstart="touchstartCallback" //手指按下
catchtouchend="touchendCallback"//手指抬起
catchtouchmove="touchmoveCallback"//移动
//事件对象 e.touches.length 根据长度判断手指数
/* chstartCallback */
if (e.touches.length === 1) {
//单指点击
let {
clientX,clientY } = e.touches[0];
this.startX = clientX;
this.startY = clientY;
}else {
//多指
//计算第一根手指与第二根手指的距离
let xMove = e.touches[1].clientX - e.touches[0].clientX;
let yMove = e.touches[1].clientY - e.touches[0].clientY;
let distance = Math.sqrt(xMove * xMove + yMove * yMove); //两直角边平方和开方算斜边
twoPoint.x1 = e.touches[0].pageX * 2
twoPoint.y1 = e.touches[0].pageY * 2
twoPoint.x2 = e.touches[1].pageX * 2
twoPoint.y2 = e.touches[1].pageY * 2
this.setData({
'stv.distance': distance,
'stv.zoom': true, //开启可缩放状态
})
}
/* touchmoveCallback*/