2014-02-27 126 views
0

我有在一个页面中div元素和绑定以下事件鼠标和触摸事件的不同浏览器和

/

/ for ie9, safari, mozilla 
    this._on(this.element, "mousedown", this.chartMouseDown); 
    this._on(this.element, "mouseup", this.chartMouseUp); 
    this._on(this.element, 'mousemove', this.chartMouseMove); 

    // for chrome 
     this._on(this.element, 'touchmove', this.chartTouchMove); 
     this._on(this.element, 'touchstart', this.chartTouchClick); 
     this._on(this.element, 'touchend', this.chartTouchClick); 

    if (window.navigator.msPointerEnabled) { 
      this._on(this.element, 'MSPointerMove', this.chartMouseMove); 
      this._on(this.element, 'MSPointerDown', this.chartMouseClick); 
     } 

上触摸div和continousous移动设备,在div必须移动根据我的手指在页面上的位置。这在Firefox,铬,Safari浏览器中工作正常,但不是在IE浏览器(拖动鼠标使用鼠标工作,通过触摸它不工作)。

我在所有的鼠标处理程序中都使用了下面的代码:例如。

chartMouseMove: function (e) { 
     e.stopPropagation(); 
     e.preventDefault(); 
     e.returnValue = false; 
     e.cancelBubble = true; 
} 

在使用触摸支持移动DIV,整个页面向上移动,并在IE浏览器下,默认的行为正在发生,我是否错过了IE浏览器的任何东西吗?

请解释如何处理各种浏览器和设备(手机|平板电脑| android)的触摸和鼠标事件。

在此先感谢

回答

1

您是否尝试过加入-ms-touch-action风格?

为了提高触摸交互的性能,它现在需要您添加到预期的触摸 目标禁用 默认触摸操作的CSS属性。

#touchTarget { 
-ms-touch-action: none; 
} 

更多信息:http://blogs.msdn.com/b/ie/archive/2011/10/19/handling-multi-touch-and-mouse-input-in-all-browsers.aspx

+0

我已经使用了,仍然面临的问题$(this.svgObject)的.css( ' - MS-触摸动作', '无'); – user3326265

1

除了什么@Dieter说,你将需要使用addEventHandler而不是$(document).on为Windows 8设备作为I pointed out the other day in your question

this.element.addEventListener("MSPointerMove", this.chartMouseMove); 
this.element.addEventListener("MSPointerDown", this.chartMousedown); 

,然后添加:

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

感谢您的更新阿尔瓦罗,我也累了,但问题仍然存在。 – user3326265

相关问题