嗨,我不知道为什么我的画布无法在移动设备上工作。
我创建了一些touchevent
。
我认为问题是touchposition
,但我无法解决。
touchstart
和touchend
事件没有问题,但在函数drawMobile(e)中没有问题
感谢您的回答。
this.touchX = 0;
this.touchY = 0;
this.canvas.addEventListener("touchmove", this.drawMobile.bind(this));
drawMobile(e) {
e.preventDefault();
this.ctx.beginPath();
this.ctx.moveTo(this.touchX, this.touchY);
this.ctx.lineTo(e.touches[0].clientX, e.touches[0].clientY);
this.ctx.stroke(); //dessine le chemin
this.touchX = e.touches[0].clientX;
this.touchY = e.touches[0].clientY;
}