7

我在使用 iPhone 时遇到问题并滑动到其他页面。向下滚动页面时,动作的灵敏度很敏感,会滑动到下一页。有没有办法在这段代码中控制滑动灵敏度:

<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

20

要针对所有设备定制此响应,我建议设置相对于屏幕宽度的阈值。例如:

$.event.special.swipe.scrollSupressionThreshold = (screen.availWidth) / 60;
$.event.special.swipe.horizontalDistanceThreshold = (screen.availWidth) / 60;
$.event.special.swipe.verticalDistanceThreshold = (screen.availHeight) / 13;

请参阅jQuery Mobile API 文档

于 2013-09-06T20:18:08.943 回答
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 回答