用代码监听413<posX<440 378<posY<404(机型iphone7  屏幕大小为375X667)   这一片区域(对应一个关闭按钮,有点击这片区域时 清除ctx)   但屏幕大小改变(如换成320X568的iphone5)   按钮对应区域不再是413<posX<440 378<posY<404了


wx.onTouchEnd(event => {

let lastTouchPoint = event.changedTouches[0];

let posX = lastTouchPoint.screenX;

let posY = lastTouchPoint.screenY;

console.log("--------------posX-----------",posX);

console.log("--------------posY-----------",posY);

let leftBoundary=413+(width-375)/2;

let rightBoundary=440+(width-375)/2;

let topBoundary=378+(height-667);

let bottomBoundary=404+(height-667);


if (posX <= rightBoundary && posX >= leftBoundary && posY >= topBoundary && posY <= bottomBoundary) {

ctx.clearRect(0, 0, sharedCanvas.width, sharedCanvas.height);

wx.offTouchEnd();

}

})



- 希望提供的能力

  试过用比例算法将范围定为413*(width/375) 等   但触点的ScreenX 与ScreenY并不与比例对应   求解触点与屏幕大小的适应关系

展开全部
收起
0回答
提交回答
  • 至过去的我

    2044人对此回答表示赞同

    我是未来的你,你现在是不是在年找寻小程序答案。你不要感觉诧异,给你来信原因,就是让你不在后悔。今天去学习如何推广小程序,相信......点击查看更多>
    发布于
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
咨询热线

13312967497

扫码添加业务即可随时咨询 还可领取小程序推广攻略

业务咨询: 13312967497
扫码咨询

扫码咨询套餐

回到顶部