From c4b05cb3e56613e711042d91bbffeab94e41abaf Mon Sep 17 00:00:00 2001 From: poikilos <7557867+poikilos@users.noreply.github.com> Date: Wed, 23 Mar 2016 21:44:14 -0400 Subject: [PATCH] working on canvas mouse position --- web/chunkymap.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/web/chunkymap.php b/web/chunkymap.php index cb2014a..b83c069 100644 --- a/web/chunkymap.php +++ b/web/chunkymap.php @@ -1078,20 +1078,24 @@ function echo_chunkymap_canvas($show_player_names_enable, $decachunks_enable, $c draw_map(); } - function getMousePos(canvas, e) { - var rect = canvas.getBoundingClientRect(); - return { - x: e.clientX - rect.left, - y: e.clientY - rect.top - }; - } + //function getMousePos(canvas, e) { + // var rect = canvas.getBoundingClientRect(); + // return { + // x: e.clientX - rect.left, + // y: e.clientY - rect.top + // }; + //} function get_relative_mouse_point(e) { var xOffset=Math.max(document.documentElement.scrollLeft,document.body.scrollLeft); var yOffset=Math.max(document.documentElement.scrollTop,document.body.scrollTop); + //return { + //x:parseInt(e.clientX+xOffset-my_canvas.offsetLeft), + //y:parseInt(e.clientY+yOffset-my_canvas.offsetTop) + //}; return { - x:parseInt(e.clientX+xOffset-my_canvas.offsetLeft), - y:parseInt(e.clientY+yOffset-my_canvas.offsetTop) + x:parseInt(e.clientX+xOffset), + y:parseInt(e.clientY+yOffset) }; }