Phonegap アプリケーションが Javascript の swipeLeft および SwipeRight 関連のイベントを認識できるかどうかを尋ねます。
5 に答える
Phonegap では、通常のモバイル Web サイトで得られるようなタッチ イベントは発生しません。つまり、UIWebView (iOS の場合) をラップするか、他のプラットフォームで同等のものをラップするだけです。
モバイル ブラウザのタッチ イベントにはtouchstart
、touchend
、touchmove
、 などがあります。
派手なスワイプ イベントやダブルタップ イベントなど、モバイル ブラウザーにネイティブに実装されているものはありません。
touchstart
ただし、javascript を在庫、touchend
イベントなどと組み合わせて使用することで、より複雑なイベントをシミュレートできます。
幸いなことに、これらのイベントをわざわざ自分で作成する必要はありません。これは、ほとんどすべてのモバイル フレームワークが自動的に作成してくれるからです。他の人は、タッチ イベントを処理するいくつかのライブラリについて言及しています。
私自身、イベントやその他の機能swipeleft
を持つ jQuery Mobile を使用する傾向があります。swiperight
http://jquerymobile.com/demos/1.2.0/docs/api/events.html
必要がなければ、完全な jQuery Mobile フレームワークを使用する必要さえありません。必要に応じて、タッチ イベント ハンドラーを含めることができます。
quo.jsを使用します。マルチタッチ イベントなどを処理するための軽量フレームワークです。
phonegapを使用してiosおよびandroidで動作するこれを使用します。
$("#test").swipe( {
click:function(event, target) {
log("click from callback");
},
swipe:function(event, direction, distance, duration, fingerCount) {
log("swipe from callback");
},
swipeLeft:function(event, distance, duration, fingerCount) {
log("swipeLeft from callback");
},
swipeRight:function(event, distance, duration, fingerCount) {
log("swipeRight from callback");
},
swipeUp:function(event, distance, duration, fingerCount) {
log("swipeUp from callback");
},
swipeDown:function(event, distance, duration, fingerCount) {
log("swipeDown from callback");
},
swipeStatus:function(event, phase, direction, distance, duration, fingers) {
log("swipeStatus from callback");
},
pinchIn:function(event, direction, distance, duration, fingerCount, pinchZoom) {
log("pinchIn from callback");
},
pinchOut:function(event, direction, distance, duration, fingerCount, pinchZoom) {
log("pinchOut from callback");
},
pinchStatus:function(event, phase, direction, distance , duration , fingerCount, pinchZoom) {
log("pinchStatus from callback");
},
fingers:$.fn.swipe.fingers.ALL
});
Zepto には、swipeLeft と swipeRight などのタッチ イベントがあります: http://zeptojs.com/#Touch%20events