Currently I need to listen for a onWheel event in react. The event gets triggered. But, I am not able to find a way to detect if user is scrolling up or scrolling down. How shall I detect that event?
const handleOnWheel = (event: React.WheelEvent<HTMLDivElement>) => {
if (event.deltaY < 0) {
console.log('Scrolling up');
} else {
console.log('Scrolling down');
}
};
This is what I was able to find online. It works well for scroll down. But, for scrolling up, both scroll down and scroll up gets printed to console.