2014-02-27 61 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

相關問題