How to determine scroll direction without actually scrolling

后端 未结 6 1340
走了就别回头了
走了就别回头了 2020-11-30 02:09

I am coding a page where the first time the user scrolls, it doesn\'t actually scroll the page down, instead it adds a class with a transition. I\'d like to detect when the

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-30 02:54

    this one work in react app

    after add event listener, in function u can use deltaY To capture mouse Wheel

    onMouseWheel = (e) => {
     e.deltaY > 0 
       ? console.log("Down")
       : console.log("up")
    }
    

提交回复
热议问题