How to get the mouse position relative to the window viewport in javascript?
Use event.clientY
to get the mouse position relative to the browser viewport (Compatibility table).
Try using event.clientY
that should always return the correct value regardless of scrolling
https://developer.mozilla.org/en-US/docs/DOM/event.clientY