2014-01-22 38 views
1

我一直在搜索互聯網,它似乎像這個問題並不總是存在Firefox的Android上。Firefox for Android無法停止觸摸滾動

我不需要停止特定元素上的觸摸滾動。

我已經試過

myElement.addEventListener('touchstart'),function(event){event.preventDefault();}); 
myElement.addEventListener('touchmove'),function(event){event.preventDefault();}); 

而且

Chrome和Safari的那些工作
document.body.addEventListener('touchstart'),function(event){event.preventDefault();}); 
document.body.addEventListener('touchmove'),function(event){event.preventDefault();}); 
document.addEventListener('touchstart'),function(event){event.preventDefault();}); 
document.addEventListener('touchmove'),function(event){event.preventDefault();}); 

組合。怎麼了Firefox? 仍然滾動。我錯過了什麼?

+0

在這個頁面上我發現FF scroll只能在touchstart上防止:http://blog.mobiscroll.com/working-with-touch-events/ – KIR

回答

0

請記住,你只是有這些事件,並儘量避免點擊,因爲它有時會混淆瀏覽器:touchstart touchend touchcancel touchleave touchmove

我想了preventDefault並不是越大越好。我使用stopImmediatePropagation代替,就像是一個preventDefault + stopPropagation

希望它有幫助!