检测触摸向上或向下滚动

Mor*_*ahi 3 javascript jquery scroll touch

我需要与触摸设备相同的代码。请帮帮我

$(window).on('DOMMouseScroll mousewheel', function (e) {
    if (ScrollEnable) {
        if (e.originalEvent.detail > 0 || e.originalEvent.wheelDelta < 0) {
            console.log('Down');
        } else {
            console.log('Up');
        }
    }
    return false;
});
Run Code Online (Sandbox Code Playgroud)

这是我的触摸代码,但是 consul 只是占用了我的网站,我需要找到它!我能做什么:|

$('body').on({
    'touchmove': function(e) {
        if (e.originalEvent.touches > 0 || e.originalEvent.touches > 0) {
            console.log('Down');
        } else {
            console.log('Up');
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

小智 5

var updated=0,st;
$('body').on({
    'touchmove': function(e) { 
    st = $(this).scrollTop();
    if(st > updated) {
        console.log('down');
    }
    else {
        console.log('up');
    }
    updated = st;
    }
});
Run Code Online (Sandbox Code Playgroud)