javascript - Get mouse position relative to a zoomed out div -
what i'm looking accomplish position of mouse in relation zoomed out div matrix transform. see in fiddle below have red div width of 4000px, since it's zoomed out appears smaller said 4000px. should happen if click on intersecting lines in red div, relx should read (around) 2000 , rely should read around 325.
$(".crazywide").click(function(e){ var clickpos = $(this).offset(); var relx = e.pagex - clickpos.left; var rely = e.pagey - clickpos.top; //used display current click coords $(".debug").empty(); $(".debug").prepend("relx: " + relx + " rely: " + rely); });
the element shrunk factor of 0.12 in both directions. such, can calculate relative mouse click position dividing relx , rely 0.12:
$(".debug").prepend("relx: " + (relx / 0.12) + " rely: " + (rely / 0.12));
Comments
Post a Comment