canvas' mouse move event's clientX is not 0 on left side #3008
Unanswered
amdreallyfast
asked this question in
Q&A
Replies: 2 comments
-
Use case:I'm trying to calculate normalized mouse coordinates for the raycaster so that I can determine what object the mouse is hovering over. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I'm attempting to compute normalized mouse coordinates rainbow obby for the raycaster in order to determine what object the mouse is hovering over. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
For my personal project, I'm using Vite with the react framework and react three fiber trying to create a canvas in a portion of the page. I expected the mouse move event's clientX to be 0 on the far left edge of the canvas, but it isn't. It seems to be following the window's screen position instead of the canvas'.
Here's a screenshot. Notice how the event's clientX as printed to the console (lower right) is still >300 at the far left edge of the canvas.

Note: Cursor does not appear in screenshot, but I circled where it was.
Packages:
Code (
App.jsx
):Note: I'm using tailwindcss for the style.
Why is the canvas' mouse move event's
clientX
not 0 on the far left of the canvas?Note: I haven't experimented with
clientY
yet because it's not a problem as long as the canvas' top edge == top of window.Beta Was this translation helpful? Give feedback.
All reactions