2013-11-15 35 views
2

我在html + Cordova/Phonegap中構建了一個塗鴉應用程序。我使用jquery(elem).on(touchstart/-move/-end)來聽touchevents。但是這似乎在Android 4.4中被打破;它只會觸發暴風雨。Android 4.4打破jquery on(touchstart/touchmove/touchend)?

任何提示?

編輯:這裏的代碼

$("#canvas_doodle").on("touchstart", function(e){ doo.touchBegin(e); }); 
$("#canvas_doodle").on("touchmove", function(e){ doo.touchMove(e); }); 
$("#canvas_doodle").on("touchend", function(e){ doo.touchEnd(e); }); 

回答

4

感謝史蒂夫P,但我想通了(忘了回答這個問題)。

不知何故,我忘了在touchBegin和touchMove中調用e.preventDefault(),這會導致touchEnd在拖動時不會觸發。

+0

但它仍然是一個問題,如果我在每個'touchstart'中調用'e.preventDefault()',它會停止網頁的正常行爲。 – Aloong

+0

@Aloong:這就是爲什麼我把聽衆附加到畫布上,而不是整個文檔:) – REJH

+0

它已近2年了,我只是想知道當你添加e.preventDefault() touchmove?如下?因爲即使當我將e.preventDefault()添加到touchmove時,我也無法使其工作。 $(「#record」)。on('touchmove',function(e){e.preventDefault();}) – John

0

嘗試:

$(document).on("touchstart", '#canvas_doodle', function(e){ doo.touchBegin(e); }); 

...