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

Suggestion to get exact mouse position #847

Open
savi8sant8s opened this issue Apr 2, 2024 · 0 comments
Open

Suggestion to get exact mouse position #847

savi8sant8s opened this issue Apr 2, 2024 · 0 comments

Comments

@savi8sant8s
Copy link

...
if (e.type === "touchmove") {
      this.mouse_x = e_pos_x;
      this.mouse_y = e_pos_y;
}
this.dispatch('mouseMove', {x: e_pos_x,y: e_pos_y });
   
//Exact mouse position
const mouse_pos_x = e_pos_x * ( this.precanvas.clientWidth / (this.precanvas.clientWidth * this.zoom)) - (this.precanvas.getBoundingClientRect().x *  ( this.precanvas.clientWidth / (this.precanvas.clientWidth * this.zoom)) );
const mouse_pos_y = e_pos_y * ( this.precanvas.clientHeight / (this.precanvas.clientHeight * this.zoom)) - (this.precanvas.getBoundingClientRect().y *  ( this.precanvas.clientHeight / (this.precanvas.clientHeight * this.zoom)) );

this.dispatch('mouseMoveExact', {x: mouse_pos_x,y: mouse_pos_y });
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant