I am trying to detect scroll direction only when the user is at the canvas
area.
I tried to replace "#myCanvas"
with "canvas"
but its not working.
Just to be sure when I change it to documnet
its works.
How can I make it work?
<canvas id="myCanvas" width="1400" height="800"></canvas>
var lastScrollTop = 0;
$("#myCanvas").on('scroll', function() {
st = $(this).scrollTop();
if(st < lastScrollTop) {
console.log('up 1');
}
else {
console.log('down 1');
}
lastScrollTop = st;
});