9

Phonegap アプリケーションが Javascript の swipeLeft および SwipeRight 関連のイベントを認識できるかどうかを尋ねます。

4

5 に答える 5

5

Phonegap では、通常のモバイル Web サイトで得られるようなタッチ イベントは発生しません。つまり、UIWebView (iOS の場合) をラップするか、他のプラットフォームで同等のものをラップするだけです。

モバイル ブラウザのタッチ イベントにはtouchstarttouchendtouchmove、 などがあります。

派手なスワイプ イベントやダブルタップ イベントなど、モバイル ブラウザーにネイティブに実装されているものはありません。

touchstartただし、javascript を在庫、touchendイベントなどと組み合わせて使用​​することで、より複雑なイベントをシミュレートできます。

幸いなことに、これらのイベントをわざわざ自分で作成する必要はありません。これは、ほとんどすべてのモバイル フレームワークが自動的に作成してくれるからです。他の人は、タッチ イベントを処理するいくつかのライブラリについて言及しています。

私自身、イベントやその他の機能swipeleftを持つ jQuery Mobile を使用する傾向があります。swiperight

http://jquerymobile.com/demos/1.2.0/docs/api/events.html

必要がなければ、完全な jQuery Mobile フレームワークを使用する必要さえありません。必要に応じて、タッチ イベント ハンドラーを含めることができます。

于 2012-12-11T23:18:47.550 に答える
4

quo.jsを使用します。マルチタッチ イベントなどを処理するための軽量フレームワークです。

于 2012-12-04T11:33:43.097 に答える
2

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 
  });
于 2013-11-09T07:48:22.743 に答える
0

Zepto には、swipeLeft と swipeRight などのタッチ イベントがあります: http://zeptojs.com/#Touch%20events

于 2012-12-11T20:46:22.340 に答える