2013-12-18 44 views
1

我有一些textarea元素,用戶可以在其中輸入消息給同伴。Phonegap中的可滾動文本區/ Cordova

這些以Phonegap WebView中的模式呈現。

當模態存在於屏幕停用滾動上web視圖體像這樣:

document.ontouchmove = function(e) { 
    e.preventDefault(); 
}; 

同樣,當我隱藏我的模態重新啓用它像這樣:

document.ontouchmove = function(e) { 
    return true; 
}; 

textarea元素似乎無法滾動觸摸事件。我看着這個,並嘗試應用以下CSS:

overflow-y: scroll; /* has to be scroll, not auto */ 
-webkit-overflow-scrolling: touch; 

但這並沒有幫助。

當用戶輸入一些長文本時,textarea會根據文本的數量進行移動,但用戶無法回滾到前一個位置。

有沒有解決方案?

+0

如果你當你的模式是在屏幕上沒有禁用滾動發生了什麼?你可以在textarea上滾動嗎? – kevpoccs

回答

1

你可以看看移動事件是否來自textarea並允許這些事件通過。

document.ontouchmove = function(e){ 
    if(e.srcElement.type !== "textarea"){ 
     e.preventDefault(); 
    } 
}; 
-2

<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script> <script src="http://code.jquery.com/mobile/1.4.3/jquery.mobile-1.4.3.min.js"></script>

添加jQuery的頭標籤移動的js ..它會工作