8

問題は、垂直スクロールが必要なときに swipeleft/swiperright イベントがトリガーされることです。

jQuery mobile 1.1.0 バージョンと jQuery 1.7.1 を使用しています。

コードは次のとおりです。

 $(document).delegate('#quizResumePage', 'swipeleft swiperight', function (event) {
   event.stopImmediatePropagation();
    if (event.type == 'swipeleft') {
       $('#btnnext').trigger('click');
    }  else  if (event.type == 'swiperight')  {
       $('#btnprevious').trigger('click');
    }
   event.preventDefault();
});

では、ページをスクロールしたいときにイベントトリガーをスワイプするのはなぜですか?

この問題は、Samsung Galaxy android 2.3.5 で発生します...

誰でもこの問題について私を助けることができますか?

4

1 に答える 1

12

次のオブジェクトの値を変更することで、スワイプ イベントの動作を制御できます。

$.extend($.event.special.swipe,{
  scrollSupressionThreshold: 10, // More than this horizontal displacement, and we will suppress scrolling.
  durationThreshold: 1000, // More time than this, and it isn't a swipe.
  horizontalDistanceThreshold: 30,  // Swipe horizontal displacement must be more than this.
  verticalDistanceThreshold: 75,  // Swipe vertical displacement must be less than this.
});

スワイプを聞く前にコードに配置してください。たとえば、verticalDistanceThreshold を 15 に、durationThreshold を 500 に変更すると、誤検知を減らすのに役立ちます。

一方、コードではボタンのクリック イベントをトリガーしていますが、それが機能している間は、次/前のアクションを実行するメソッドを直接呼び出す方が適切です。

幸運を!

于 2012-08-20T19:44:18.593 に答える