Javascript 触摸屏中的事件

Javascript 触摸屏中的事件,javascript,jquery,Javascript,Jquery,我已经将mousemove和mousedown事件绑定到div元素,如下所示。在firefox中,每次我将手指移到div元素上时,事件get都会触发。但在ie/chrome中,只有当我第一次触摸div时才会触发事件,手指不停地在div上移动,不会像firefox中那样触发事件 this._on(this.element, 'mousemove', this.chartMouseMove); this._on(this.element, 'mousedown', this.chartMousedo

我已经将mousemove和mousedown事件绑定到div元素,如下所示。在firefox中,每次我将手指移到div元素上时,事件get都会触发。但在ie/chrome中,只有当我第一次触摸div时才会触发事件,手指不停地在div上移动,不会像firefox中那样触发事件

this._on(this.element, 'mousemove', this.chartMouseMove);
this._on(this.element, 'mousedown', this.chartMousedown);
注意:鼠标事件被触发(移动鼠标指针触发事件),只有触摸不起作用(移动手指不起作用)

我想让鼠标移动在我移动手指时触发


提前感谢对于触摸设备,您应该使用
touchmove
touchStart

this._on(this.element, 'touchmove', this.chartMouseMove);
this._on(this.element, 'touchstart', this.chartMousedown);
如果要使其与Windows Phone兼容,还应添加
MSPointerDown
MSPointerMove

this._on(this.element, 'touchmove MSPointerMove', this.chartMouseMove);
this._on(this.element, 'touchstart MSPointerDown', this.chartMousedown);
如果您需要处理Windows 8触摸设备,则需要使用
addEventHandler
而不是
on

this.element.addEventListener("MSPointerMove", this.chartMouseMove);
this.element.addEventListener("MSPointerDown", this.chartMousedown);
此外,您还需要在身体中应用以下样式:

body{
    -ms-touch-action: none;
}

如果您不介意使用插件,我建议您使用使其简单化:)

感谢您的更新,但这不起作用。chartMousedown方法在我每次触摸div时都会被调用(即mouseDown正在工作),为什么mouseMove不工作working@user3326265您正在使用哪种触摸设备?使用windows触摸lap8@user3326265我更新了针对Windows 8设备的问题。还推荐了一个插件。如果答案对你有效,你应该接受。