Detect scrolling attempts in overflow:hidden page?

前端 未结 2 1657
萌比男神i
萌比男神i 2021-01-18 08:18

I want to detect when the user is trying to scroll up or down on my page, but since I don\'t want to allow the actual scrolling I have set an overflow:hidden body. The code

2条回答
  •  死守一世寂寞
    2021-01-18 09:01

    Here's a jQuery-solution.

    $(document).bind('mousewheel', function(e) {
        var delta = e.originalEvent.wheelDelta;
        console.log('The mouse delta is : ' + delta);
    });
    

    jQuery Doc - .bind()

提交回复
热议问题