Drawflow icon indicating copy to clipboard operation
Drawflow copied to clipboard

Suggestion to get exact mouse position

Open savi8sant8s opened this issue 1 year ago • 0 comments

...
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 });
...

savi8sant8s avatar Apr 02 '24 12:04 savi8sant8s