CHANNELS:

All
r
raphaelBaere posted 11 days ago
chris posted 7 days ago

Is there any margin between your canvas and your browser window? Any bit of spacing can throw off your mouse position, so you'd need to add that bit of offset to your equation when detecting for coordinates.

You can get an element's offset with getBoundingClientRect(): https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect

0

Want to participate?

Create a free Chris Courses account to begin

or
Sign In

Providing the lift to launch your development career

© 2022 Chris Courses. All rights reserved.