I have handleScroll
callback
<div onScroll={handleScroll} >
And handleScroll
is called when mouse whell is touched.
const handleScroll = (e) =>{
console.log("handlescroll clientX",e.clientX);
console.log("handlescroll clientY",e.clientY);
However it doesn’t have mouse poitner position.
So, I think there are two methods.
1 Get the mouse pointer position in scroll callback
2 Get the mouse pointer potition by spontaneously (not by callback)
Either way is possible?
2
Answers
The only way to get the mouse position is with events. There is no way to get it without callbacks.
You can see more here: How to get the mouse position without events (without moving the mouse)?
You are doing it the right way.
For the second method you can do it without using callbacks.
Do let me know how it works for you.