2011-11-08 29 views
0

我真的在Phonegap和JQuery的Android應用上掙扎。手指從左向右移動時如何獲得實時位置?

我想要做的就是當我從左至右拖動手指時,我希望能夠輸出到屏幕到我的x位置是什麼。

我不能使用touchmove,因爲它只是給出了運動結束時的座標,我需要實時座標嗎?

有沒有我可以使用的任何JQuery插件?

有沒有人有任何想法?

回答

1

這應該工作:

text = document.getElementById('element to hold text'); // element that can write the x position 

document.getElementById('element').ontouchmove = function (e) 
{e.preventDefault(); 
e.stopPropagation(); 
text.innerHTML = e.touches[0].clientX; //set the inner html of the text element to be the x position of the touch 
}; 
-2

首先你說appp然後你說jquery?

這怎麼可能?

反正在應用程序的情況下,你可以使用

OnTouchListener 

而對於網絡就可以使用

MouseMove事件(或)

Click事件

所有這三個方法將具有作爲參數

的位置
+1

可以使用PhoneGap的開發應用程序時使用JQuery。檢測觸摸很簡單。 Touchmove只提供運動的終點,而不是當前位置 - 這正是我想要的。 – ojsglobal

+0

View.OnTouchListener可以滿足您的要求。 –

+0

但是這怎麼整合到PhoneGap中? – ojsglobal

相關問題