为什么我的touchmove事件无法绘制画布?

时间:2019-08-07 13:06:55

标签: javascript canvas mobile touch-event

嗨,我不知道为什么我的画布无法在移动设备上工作。

我创建了一些touchevent。 我认为问题是touchposition,但我无法解决。 touchstarttouchend事件没有问题,但在函数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;
   }

0 个答案:

没有答案