如何在iPhone上禁用向左/向右滑动

时间:2018-10-09 15:36:33

标签: javascript

我正在使用地平线滚动插件: https://github.com/trgraglia/jquery.horizonScroll.js

在iphone上,滑动并不完美-每次尝试向下滚动时,页面都会前进到下一个“幻灯片”。

因此,想法是禁用向右/向左滑动,而只需让用户单击向左/向右箭头即可导航。

我使用了以下代码:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
<!--<script type="text/javascript" src="js/jquery.touchSwipe.js"></script>-->
<script type="text/javascript" src="js/jquery.horizonScroll.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>

$('section').horizon();

    // If you do not want to include another plugin, TouchSwipe, 
    //you can set it to false in the default options by passing in the option as false.
    //But when I use this code, then the sections advance
    //two at a time instead of one at a time
    //$('section').horizon({swipe: false}); 

args = self.options.swipeArgs || 
        {fallbackToMouseEvents: false,
            allowPageScroll: "horizontal",
            swipe: function(e, dir) {
            if (dir === 'left' || dir === 'right')
                return false;
            }};
        $('section').swipe(args); //only works on android

        $('body').bind('touchmove', function(e){e.preventDefault()}); 
       //doesn't affect ios

有人知道如何禁用iPhone的向左/向右滑动吗?

0 个答案:

没有答案