当用户向下滚动其移动设备的页面时,我想禁用touchstart事件。该页面具有各种元素,当您单击时可以切换一个类,但是我希望在用户向下滑动以向下滚动页面时,可以禁用touchstart事件。

JQUERY

$(document).on('touchstart click', '.flip-container ', function(event){
         event.preventDefault();
        $(this).find('.flipper').toggleClass('hover');
});


任何人知道如何吗?谢谢!

最佳答案

var touchmoved;
$('button').on('touchend', function(e){
    if(touchmoved != true){
        // you're on button click action
    }
}).on('touchmove', function(e){
    touchmoved = true;
}).on('touchstart', function(){
    touchmoved = false;
});


https://stackoverflow.com/a/32120668/3678996

关于jquery - 在手机上滚动页面时防止touchstart,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20615605/

10-11 06:06