Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canvas mouse events coord is wrong on layout change #200

Open
ProtonGustave opened this issue Dec 25, 2022 · 1 comment
Open

Canvas mouse events coord is wrong on layout change #200

ProtonGustave opened this issue Dec 25, 2022 · 1 comment

Comments

@ProtonGustave
Copy link

You calculate local coordinates there based on evt.pageX/evt.pageY and canvas page bounds. Element page bounds variable gets updated on "resize" page event(and manual "resize" calls), but page layout may be changed all the time(some data is loaded and element above chart became bigger for example).
Easiest fix is to use evt.offsetX/evt.offsetY, but this also highlight problem with "bounds" variable, better not to use it if possible since there is no performant tracker of element position.

@williamngan
Copy link
Owner

You're right that it's not ideal as it'll take some manual calculations for advanced layout changes. I think I encountered some issue with offsetX/offsetY (maybe it's not supported by touch event, or some other issues).

Worth revisiting and improve this one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants