7

I'm having an issue with the iPhone and swiping to other pages. When scrolling down a page the sensitivity of the motion is touchy and will swipe to the next page. Is there a way to control swipe sensitivity within this code:

<script type="text/javascript">
$(document).ready(function(){
    var counter = 1;
    $(document).bind('swipeleft','#deal_1',function (event, ui) {
    counter++;
    if(counter>3)
    counter = 1;
    var nextpage = 'dailydeal'+counter+'.html';
    if (nextpage.length > 0) {
        $.mobile.changePage(nextpage, {transition: "slide",
        reverse: false}, true, true);
        }
    });
 $(document).bind('swiperight','#deal_1',function (event, ui) {
     counter--;
     if(counter<1)
     counter=3;
     var prevpage = 'dailydeal'+counter+'.html';
     if (prevpage.length > 0) {
         $.mobile.changePage(prevpage, {transition: "slide",
         reverse: true}, true, true);
     }
     });
  });
</script>
4

2 に答える 2

7

これはほとんどの場合うまくいくようです:

<script type="text/javascript">
    $(document).bind("mobileinit", function () {
    $.event.special.swipe.horizontalDistanceThreshold = 100;
    });
</script>

私の理解では、 horizo​​ntalDistanceThreshold はデフォルトで 30px に設定されているので、100 に変更しました。これまでのところ、下にスクロールするとバランスが取れており、過敏になりすぎないようです。

于 2013-05-24T14:58:36.557 に答える