CHANNELS:

All
chris posted a year 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

© 2024 Chris Courses. All rights reserved.