Catch scrolling event on overflow:hidden element

后端 未结 4 1741
醉话见心
醉话见心 2020-12-01 13:53

Any insights on how to catch a scrolling event on a element that has overflow:hidden? I would like to scroll in a column without showing a scrollbar to the user.

4条回答
  •  [愿得一人]
    2020-12-01 14:28

    $("div").on('wheel', function (e) {
            if (e.originalEvent.deltaY < 0) {
            console.log("Scroll up");
        } else {
            console.log("Scroll down");
        }
    });
    

    This did the trick for me. JSFiddle

    StackFiddle:

    $("div").on('wheel', function(e) {
      if (e.originalEvent.deltaY < 0) {
        console.log("Scroll up");
      } else {
        console.log("Scroll down");
      }
    });
    div {
      height: 50px;
      width: 300px;
      background-color: black;
      overflow: hidden;
    }
    
    
    

提交回复
热议问题